hi all
Hello. I have weird behavior when comparing native JavaScript Objects with =
in advanced compilation. My app receives a JavaScript object from an npm api. In development (= js-obj nil)
works as expected. But in the advanced copiled code it returns a truthy value when js-obj
is provided. Is this expected behavior or does the =
work the same in normal and advanced compilation and I am missing something else?
@witek I don't understand what you mean by comparing?
w/ js objs you can only compare if they are identical or not w/ =
not identical in contents
identical in memory
Just to add to the above - the only reason that I can think of for why (= js-obj nil)
can return true
in prod and false
in dev is that something got its name mangled up the call chain, and that form does indeed receive nil
.
And if you just need to check for nil
, use nil?
.
Thank you for feedback. I was getting a user object from an auth library multiple times. My goal was to do something when the user changed. So I stored the user in an atom. Then when I received anoter user I "compared" it to the one from the atom. Given (def USER (atom nil))
and a JavaScript object user
. In dev (= user @USER)
returned false
while in production it returned ee
(a JavaScript object) which was truthy. I replaced my comparsion with (identical? user @USER)
and it works now. I really would like to understand this 😞
The first step would be to build a minimal reproducible example.
Given the strangeness of the situation, it's likely that you won't be able to create one from scratch. If that's the case, I'd go the other way - keep removing bits from the actual app till you can't reproduce the issue anymore.
Thank you. I will continue to debug. I posted here, just in case I missed something with the =
operator in ClojureScript.
Hi, Clojurians! Can anyone tell me how to better track down what's going on with an error I'm getting while compiling an uberjar: "java.lang.IllegalArgumentException: No matching clause for: none". It seems like it's coming from a case statement, but the stack trace is completely opaque, and removing the only case statements I wrote doesn't help, so my current hypothesis is that it's coming from some dependency.
looks like you maybe have none
in your CLJS build config somewhere? as in a symbol when it should be a :none
keyword? or well :advanced
for release stuff?
You, sir, are a gentleman and a scholar. I had ":optimizations none", and adding the colon did it.