From da082e79ffe325731e92397685cafbab19964357 Mon Sep 17 00:00:00 2001 From: Travis Vachon Date: Sun, 8 Dec 2013 21:43:23 -0500 Subject: [PATCH] Fix property access syntax inside go blocks We need to special case ClojureScript's property access syntax. --- src/main/clojure/cljs/core/async/impl/ioc_macros.clj | 4 +++- src/test/cljs/cljs/core/async/runner_tests.cljs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 bfa775f..68a0139 100644 --- a/src/main/clojure/cljs/core/async/impl/ioc_macros.clj +++ b/src/main/clojure/cljs/core/async/impl/ioc_macros.clj @@ -290,7 +290,9 @@ (block-references [this] []) IEmittableInstruction (emit-instruction [this state-sym] - `[~(:id this) (. ~target ~(cons method args))])) + (if (.startsWith (name method) "-") + `[~(:id this) (. ~target ~method)] + `[~(:id this) (. ~target ~(cons method args))]))) (defrecord Jmp [value block] IInstruction diff --git a/src/test/cljs/cljs/core/async/runner_tests.cljs b/src/test/cljs/cljs/core/async/runner_tests.cljs index 655e54f..083f1c8 100644 --- a/src/test/cljs/cljs/core/async/runner_tests.cljs +++ b/src/test/cljs/cljs/core/async/runner_tests.cljs @@ -102,6 +102,12 @@ (runner (set! test-target 42)) (is= test-target 42)) + (testing "property access" + (let [x (js-obj)] + (set! (.-foo x) 42) + (is= 42 (runner (.-foo x))) + (is= 42 (runner (. x -foo))))) + (testing "keywords as functions" (is (= :bar (runner (:foo (pause {:foo :bar})))))) -- 1.8.3.4 (Apple Git-47)