diff --git a/src/main/clojure/cljs/core/async/impl/ioc_macros.clj b/src/main/clojure/cljs/core/async/impl/ioc_macros.clj index e3ae7c35..e72ba0cb 100644 --- a/src/main/clojure/cljs/core/async/impl/ioc_macros.clj +++ b/src/main/clojure/cljs/core/async/impl/ioc_macros.clj @@ -383,7 +383,16 @@ syms (map first parted) inits (map second parted)] (gen-plan - [local-val-ids (all (map item-to-ssa inits)) + [local-val-ids (all (map ; parallel bind + (fn [sym init] + (gen-plan + [itm-id (item-to-ssa init) + _ (push-alter-binding :locals assoc sym itm-id)] + itm-id)) + syms + inits)) + _ (all (for [x syms] + (pop-binding :locals))) local-ids (all (map (comp add-instruction ->Const) local-val-ids)) body-blk (add-block) final-blk (add-block) diff --git a/src/main/clojure/clojure/core/async/impl/ioc_macros.clj b/src/main/clojure/clojure/core/async/impl/ioc_macros.clj index 5f70d032..f70c0adf 100644 --- a/src/main/clojure/clojure/core/async/impl/ioc_macros.clj +++ b/src/main/clojure/clojure/core/async/impl/ioc_macros.clj @@ -381,7 +381,16 @@ syms (map first parted) inits (map second parted)] (gen-plan - [local-val-ids (all (map item-to-ssa inits)) + [local-val-ids (all (map ; parallel bind + (fn [sym init] + (gen-plan + [itm-id (item-to-ssa init) + _ (push-alter-binding :locals assoc sym itm-id)] + itm-id)) + syms + inits)) + _ (all (for [x syms] + (pop-binding :locals))) local-ids (all (map (comp add-instruction ->Const) local-val-ids)) body-blk (add-block) final-blk (add-block) diff --git a/src/test/cljs/cljs/core/async/runner_tests.cljs b/src/test/cljs/cljs/core/async/runner_tests.cljs index 7151b4a2..449e864e 100644 --- a/src/test/cljs/cljs/core/async/runner_tests.cljs +++ b/src/test/cljs/cljs/core/async/runner_tests.cljs @@ -15,8 +15,8 @@ (deftest runner-tests (testing "macros add locals to the env" (is= :pass - (runner (let [x 42] - (pause (locals-test)))))) + (runner (let [x 42] + (pause (locals-test)))))) (testing "do blocks" (is= 42 (runner (do (pause 42)))) @@ -46,10 +46,14 @@ (recur (inc (pause x))) (pause x))))) (is= [:b :a] - (runner (loop [a :a b :b n 1] - (if (pos? n) - (recur b a (dec n)) ;; swap bindings - [a b]))))) + (runner (loop [a :a b :b n 1] + (if (pos? n) + (recur b a (dec n)) ;; swap bindings + [a b])))) + (is= 1 + (runner (loop [x 0 + y (inc x)] + y)))) (testing "let expressions" (is= 3 diff --git a/src/test/clojure/clojure/core/async/ioc_macros_test.clj b/src/test/clojure/clojure/core/async/ioc_macros_test.clj index 2ae8a9e7..74ddb165 100644 --- a/src/test/clojure/clojure/core/async/ioc_macros_test.clj +++ b/src/test/clojure/clojure/core/async/ioc_macros_test.clj @@ -73,7 +73,11 @@ (runner (loop [a :a b :b n 1] (if (pos? n) (recur b a (dec n)) ;; swap bindings - [a b])))))) + [a b]))))) + (is (= 1 + (runner (loop [x 0 + y (inc x)] + y))))) (testing "let expressions" (is (= 3