Skip to content

Commit

Permalink
ASYNC-212: fix expressions with nil local
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Miller <alex.miller@cognitect.com>
  • Loading branch information
Bronsa authored and puredanger committed Jan 9, 2020
1 parent b74d475 commit 78f5ab3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/clojure/clojure/core/async/impl/ioc_macros.clj
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,9 @@
(defrecord RawCode [ast locals]
IInstruction
(reads-from [this]
(keep (or locals #{})
(map :name (-> ast :env :locals vals))))
(for [local (map :name (-> ast :env :locals vals))
:when (contains? locals local)]
(get locals local)))
(writes-to [this] [(:id this)])
(block-references [this] [])
IEmittableInstruction
Expand All @@ -236,8 +237,7 @@
`[~@(->> (-> ast :env :locals vals)
(map #(select-keys % [:op :name :form]))
(filter (fn [local]
(when locals
(get locals (:name local)))))
(contains? locals (:name local))))
set
(mapcat
(fn [local]
Expand Down
9 changes: 9 additions & 0 deletions src/test/clojure/clojure/core/async/ioc_macros_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -529,3 +529,12 @@
(catch UnsupportedOperationException ex
:unsupported)))]
(is (= :ok resp))))

(deftest ASYNC-212
(is (= 42
(<!! (go
(let [a nil
foo (identity a)]
(if foo
(<! foo)
42)))))))

0 comments on commit 78f5ab3

Please sign in to comment.