Skip to content

Commit 1cbdd32

Browse files
committed
compile time tests for disallowing & as local binding
1 parent 4a8e755 commit 1cbdd32

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/test/clojure/cljs/compiler_tests.clj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,30 @@
401401
(if (gobject/containsKey nil nil) true false)]))]
402402
(is (nil? (re-find #"truth_" code))))))
403403

404+
(deftest test-amp-as-local-clj-2954
405+
(testing "& disallowed as local binding"
406+
(try
407+
(env/with-compiler-env (env/default-compiler-env)
408+
(compile-form-seq
409+
'[(let [& 42] &)]))
410+
(catch Throwable t
411+
(is (instance? clojure.lang.ExceptionInfo t))
412+
(is (.startsWith (-> t ex-cause ex-message) "Can't use & as a local binding"))))
413+
(try
414+
(env/with-compiler-env (env/default-compiler-env)
415+
(compile-form-seq
416+
'[(let* [& 42] &)]))
417+
(catch Throwable t
418+
(is (instance? clojure.lang.ExceptionInfo t))
419+
(is (.startsWith (-> t ex-cause ex-message) "Can't use & as a local binding"))))
420+
(try
421+
(env/with-compiler-env (env/default-compiler-env)
422+
(compile-form-seq
423+
'[(loop* [& 42] &)]))
424+
(catch Throwable t
425+
(is (instance? clojure.lang.ExceptionInfo t))
426+
(is (.startsWith (-> t ex-cause ex-message) "Can't use & as a local binding"))))))
427+
404428
;; CLJS-1225
405429

406430
(comment

0 commit comments

Comments
 (0)