The following code should evaluate to true
:
((or int? string?) 1)
But instead it evaluates to the int?
function. In other words this evaluates to true
:
(= int? ((or int? string?) 1))
What???
This is because the JavaScript generated for ((or int? string?) 1)
is
(cljs.core.int_QMARK_) || (cljs.core.string_QMARK_).call(null,(1))
which short-circuits, evaluating to cljs.core.int_QMARK_
. The fix is the addition of some needed parens.
This likewise affects and
. But to see that you need a prefix operator.
If you evaluate this code
(js-delete (and int? string?) "bogus-property")
it should be the same as
(js-delete string? "bogus-property")
which is harmless. But the JavaScript generated for the original form is
delete (cljs.core.int_QMARK_) && (cljs.core.string_QMARK_)["bogus-property"]
and, poof!, the int?
function is gone with the wind. This now evaluates to false
.
(exists? int?)
Fixes for these landed in ClojureScript master.