4

I have a problem with ClojureScript Core-Async . This only happens in ClojureScript and not in Clojure.

I have the following code:

(defn cc [x]
  (go 
    (println "cc: " x)
    x))

(defn foo [x]
  (go
    (when (and (= :ok (<! (cc x)))
               (= :ok (<! (cc :ok))))
      (print "after and"))))

(foo 1)
(foo :ok)

When calling (foo :ok), the result is as expected - the function cc is called twice, and the console shows cc: :ok cc: :ok after and. But, when running (foo 1), the function cc is also run twice and the console shows cc: 1 cc: :ok. So, even though the first condition isn't fullfilled, the second one is still checked!

3
  • This sounds like a bug, not a question; I suggest you report a github issue for the project and report the version number. Jan 26, 2016 at 19:35
  • @TimothyPratley you are right. This is a bug. I opened a Jira issue for it: dev.clojure.org/jira/browse/ASYNC-158
    – Asher
    Jan 27, 2016 at 6:37
  • Groovy! Thank you for reporting it. Jan 27, 2016 at 15:32

1 Answer 1

1

This is apparently a bug with the ClojureScript core.async library. I opened a Jira issue for this.

In the meantime I was able to work around this by using:

(go
  (when (= :ok (<! (cc x))
    (when (= :ok (<! (cc :ok)))
      (print "after and")))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.