When a doseq appears in non-terminal position inside a do block, it "iterates" repeatedly over the first element only.
This only affects bootstrapped clojurescript, but can be supported with a vanilla cljs.js setup and the last example below.
Correctly prints 1 and then 2:
(do :before (doseq [x [1 2]] (println x)))
Correctly does not iterate, and returns :after
(do (doseq [x []] (println x)) :after)
Incorrectly prints 1 ad infinitum
(do (doseq [x [1 2]] (println x)) :after)
Example code including bootstrapping:
(def source "(do (doseq [e [1 2]] (println e)) 3)") (cljs/eval-str (cljs/empty-state) source source {:eval cljs/js-eval :source-map false :verbose true} prn)
For convenience a repo to run this example is here:
https://github.com/crisptrutski/do-doseq-bootstrapped
Confirmed that fix works downstream in Planck.
fixed https://github.com/clojure/clojurescript/commit/3636a80c9b683cdc1190bd60910bf805e6ab22c0
Mind if I close this as superceded by http://dev.clojure.org/jira/browse/CLJS-1435?
The latter makes a better test case (failure terminates...)
See also CLJS-1435
If you're are going to mention commits, please link to them thanks.
When a doseq appears in non-terminal position inside a do block, it "iterates" repeatedly over the first element only.
This only affects bootstrapped clojurescript, but can be supported with a vanilla cljs.js setup and the last example below.
Correctly prints 1 and then 2:
(do :before (doseq [x [1 2]] (println x)))
Correctly does not iterate, and returns :after
(do (doseq [x []] (println x)) :after)
Incorrectly prints 1 ad infinitum
(do (doseq [x [1 2]] (println x)) :after)
Example code including bootstrapping:
(def source "(do (doseq [e [1 2]] (println e)) 3)") (cljs/eval-str (cljs/empty-state) source source {:eval cljs/js-eval :source-map false :verbose true} prn)
For convenience a repo to run this example is here:
https://github.com/crisptrutski/do-doseq-bootstrapped