File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2510,13 +2510,14 @@ x (not (contains? ret :info)))
25102510 (loop [bes []
25112511 env (assoc encl-env :context :expr )
25122512 bindings (seq (partition 2 bindings))]
2513-
25142513 (if-some [[name init] (first bindings)]
2515- (let []
2514+ (do
25162515 (when (or (some? (namespace name))
25172516 #?(:clj (.contains (str name) " ." )
25182517 :cljs ^boolean (goog.string/contains (str name) " ." )))
25192518 (throw (error encl-env (str " Invalid local name: " name))))
2519+ (when (= '& name)
2520+ (throw (error encl-env " Can't use & as a local binding" )))
25202521 (let [init-expr (analyze-let-binding-init env init (cons {:params bes} *loop-lets*))
25212522 line (get-line name env)
25222523 col (get-col name env)
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments