Skip to content

Commit 848e10a

Browse files
committed
CLJS-2956: Stack overflow when specing core =
1 parent 820e6fa commit 848e10a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/cljs/cljs/spec/test/alpha.cljc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ returns the set of all symbols naming vars in those nses."
4646
(defmacro with-instrument-disabled
4747
"Disables instrument's checking of calls, within a scope."
4848
[& body]
49-
`(let [orig# @#'*instrument-enabled*]
49+
;; Note: In order to read the value of this private var, we employ interop
50+
;; rather than derefing a var special. This eases specing core functions
51+
;; (and infinite recursion) by avoiding code generated by the var special,
52+
;; and also produces more compact / efficient code.
53+
`(let [orig# (.-*instrument-enabled* js/cljs.spec.test.alpha)]
5054
(set! *instrument-enabled* nil)
5155
(try
5256
~@body

src/test/cljs/cljs/spec/test_test.cljs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@
111111
(fn-2953 "abc"))))
112112
(is @#'stest/*instrument-enabled*))
113113

114+
(s/fdef cljs.core/= :args (s/+ any?))
115+
116+
(deftest test-cljs-2956
117+
(stest/instrument 'cljs.core/=)
118+
(is (true? (= 1)))
119+
(is (thrown? js/Error (=)))
120+
(stest/unstrument 'cljs.core/=))
121+
114122
(defn fn-2975 [x])
115123

116124
(deftest test-2975

0 commit comments

Comments
 (0)