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. Commented 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 Commented Jan 27, 2016 at 6:37
  • Groovy! Thank you for reporting it. Commented 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")))))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.