Skip to content

Commit

Permalink
fix for ASYNC-17, parallel loop bindings don't work
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Aug 9, 2013
1 parent 018d26a commit d445dd3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
11 changes: 10 additions & 1 deletion src/main/clojure/cljs/core/async/impl/ioc_macros.clj
Expand Up @@ -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)
Expand Down
11 changes: 10 additions & 1 deletion src/main/clojure/clojure/core/async/impl/ioc_macros.clj
Expand Up @@ -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)
Expand Down
16 changes: 10 additions & 6 deletions src/test/cljs/cljs/core/async/runner_tests.cljs
Expand Up @@ -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))))
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/test/clojure/clojure/core/async/ioc_macros_test.clj
Expand Up @@ -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
Expand Down

0 comments on commit d445dd3

Please sign in to comment.