Skip to content

Commit 293b7dd

Browse files
mfikesswannodette
authored andcommitted
CLJS-2101: Undeclared var in do chain of defs
We need to force the compiler state analysis side effects which occur when analyzing the chain of forms inside do form, prior to analyzing the last form in the do.
1 parent 97c166c commit 293b7dd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/main/clojure/cljs/analyzer.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@
16661666
:children (conj (vec (map :init bes)) expr)}))
16671667

16681668
(defn analyze-do-statements* [env exprs]
1669-
(seq (map #(analyze (assoc env :context :statement) %) (butlast exprs))))
1669+
(seq (doall (map #(analyze (assoc env :context :statement) %) (butlast exprs)))))
16701670

16711671
(defn analyze-do-statements [env exprs]
16721672
(disallowing-recur (analyze-do-statements* env exprs)))

src/test/clojure/cljs/analyzer_tests.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,18 @@
721721
(let [def (get-in @test-cenv [::a/namespaces 'test.cljs-1992 :defs 'test-fn])]
722722
(is (:fn-var def)))))
723723

724+
(deftest test-cljs-2101
725+
(let [test-cenv (e/default-compiler-env)]
726+
(e/with-compiler-env test-cenv
727+
(a/analyze-form-seq
728+
['(ns test.cljs-2101)
729+
`(do
730+
;; Splice in 32 forms in order to consume first chunk in chunked sequence
731+
~@(range 32)
732+
(def ~'x32 1)
733+
;; The previous def must be analyzed for subsequent var special to succeed
734+
(def ~'x33 (var ~'x32)))]))))
735+
724736
(comment
725737
(binding [a/*cljs-ns* a/*cljs-ns*]
726738
(a/no-warn

0 commit comments

Comments
 (0)