This is a weird one! Given a test like the following:
(is (thrown? :default (subs nil 1 2)))
I expect that to pass. If I run shadow-cljs watch test where :test refers to my build entry, it passes as expected.
If I run:
shadow-cljs release test
node target/js/node-tests.js
The assertion fails with the assertion:
FAIL in (test-subs) (clojure/core_test/subs.cljc:20:14)
expected: (thrown? :default (subs nil 1 2))
actual: nil
Any thoughts as to what's causing that? I'm using the default cljs test runnerNarrowed it down to :optimizations :simple vs :optimizations :advanced
Narrowed it down further, the :advanced optimization is inlining the tests calling subs to "string".substring(x, y), but in the case of (subs nil 1 2), I think the google closure compiler is factoring it out as it knows null.substring(1, 2) is not valid code
I think that confirms this is not an issue with shadow, likely just a side-effect from the google closure compiler
interesting. is there no compiler error/warning at all? what is left in the code?
Correct, no warning or error from the compiler. I’ll create a mini reproduction repo. Unfortunately, it’s unclear precisely what the code compiles to right now https://media.discordapp.net/attachments/1332619461026648065/1332628554797813780/CleanShot_2025-01-25_at_03.29.462x.png?ex=6795f28e&is=6794a10e&hm=a413119901cf5f143c4cc1748417a2fc99accc5e82668f7e596da8509dd0f782&
But based on the error we get in ci it seems (is (thrown? (subs nil 1 2))) is optimized to something like (is (thrown? nil)) which causes that test to fail.
Here's a very minimal reproduction repo