This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-04-09
Channels
- # aleph (1)
- # asami (5)
- # babashka (4)
- # beginners (8)
- # biff (19)
- # calva (2)
- # cider (14)
- # clojure (17)
- # clojure-dev (3)
- # clojure-europe (3)
- # clojurescript (2)
- # community-development (9)
- # conjure (1)
- # core-typed (2)
- # datomic (6)
- # emacs (20)
- # gratitude (1)
- # helix (5)
- # kaocha (4)
- # nbb (1)
- # releases (3)
- # testing (17)
Should this really be an error?
(defn g
[]
(loop [rawMode (= 1 2)]
(recur true)))
yields
Syntax error (IllegalArgumentException) compiling fn* at (REPL:1:1).
recur arg for primitive local: rawMode is not matching primitive, had: java.lang.Boolean, needed: boolean
(this is cut down from a much larger example that actually did something real, not just an infinite loop.)
BTW, the following defn
works just fine:
(defn f
[]
(loop [rawMode (or false (= 1 2))]
(recur true)))
(This was my workaround to get my code running. There are other tactics that could be applied.)
If you think this looks funny, it looks funnier in ClojureCLR, where there is not java.lang.Boolean/boolean wrapper/primitive distinction. ClojureCLR delivers the wonderful message:
recur arg for primitive local: rawMode is not matching primitive, had: Boolean, needed Boolean
which is just silly. (`Boolean` is the primitive type (value type), not a wrapper.)
I know where/why this happens and I think I have a fix, but I certainly won't go further if this is the desired behavior.📦 2