clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
km 2021-03-15T07:06:42.343100Z

hi all

2👋
witek 2021-03-15T19:02:06.349200Z

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?

dnolen 2021-03-15T19:47:10.350300Z

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

dnolen 2021-03-15T19:47:22.350700Z

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

dnolen 2021-03-15T19:47:31.350900Z

not identical in contents

dnolen 2021-03-15T19:47:36.351200Z

identical in memory

p-himik 2021-03-15T19:54:26.352700Z

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

witek 2021-03-15T20:11:44.358900Z

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-himik 2021-03-15T20:23:56.359200Z

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

p-himik 2021-03-15T20:25:00.359400Z

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.

witek 2021-03-15T20:31:23.359600Z

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

Brendan Foote 2021-03-15T21:33:44.362800Z

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.

thheller 2021-03-15T21:36:05.363300Z

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 Foote 2021-03-15T21:54:54.364200Z

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