Details
-
Type:
Defect
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Completed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
This seems to be a subtler version of CLJS-39:
(let [fs (atom [])]
(doseq [x (range 4)
:let [y (inc x)
f (fn [] y)]]
(swap! fs conj f))
(map #(%) @fs))
;; => (4 4 4 4)
;; should be (1 2 3 4)
I think this example is minimal. The bug is not present if we use a proper let.
It appears that this works correctly on current master. In fact, it worked correctly on r1576 – but not on r1552. Also, splitting the :let into two ("adjacent") :let's fixes this, whereas moving both the y and f bindings into a single regular let inside the doseq does not. That means it's probably an instance of
CLJS-442(fns defined in local init exprs not closing over earlier locals), fixed in https://github.com/clojure/clojurescript/commit/84e9488f49bcfea4b4037a562f8f797c7ddd79f0 (included in releases since r1576).CLJS-442(fns defined in local init exprs not closing over earlier locals), fixed in https://github.com/clojure/clojurescript/commit/84e9488f49bcfea4b4037a562f8f797c7ddd79f0 (included in releases since r1576).