Fork me on GitHub
#clojurescript
<
2021-03-15
>
km07:03:42

hi all

👋 6
witek19:03:06

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?

dnolen19:03:10

@witek I don't understand what you mean by comparing?

dnolen19:03:22

w/ js objs you can only compare if they are identical or not w/ =

dnolen19:03:31

not identical in contents

dnolen19:03:36

identical in memory

p-himik19:03:26

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?.

witek20:03:44

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 😞

p-himik20:03:56

The first step would be to build a minimal reproducible example.

p-himik20:03:00

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.

witek20:03:23

Thank you. I will continue to debug. I posted here, just in case I missed something with the = operator in ClojureScript.

Brendan Foote21:03:44

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.

thheller21:03:05

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?

Brendan Foote21:03:54

You, sir, are a gentleman and a scholar. I had ":optimizations none", and adding the colon did it.