coax icon indicating copy to clipboard operation
coax copied to clipboard

CLJS compilation warnings

Open thheller opened this issue 3 months ago • 2 comments

This was fixed before via #13, #19 but was incorrectly reverted in the https://github.com/exoscale/coax/commit/11bbfc95334fa194832382c0142cd0a93b1030ca commit.

That commit seems to have been written with the assumption that the macro in utils.cljs is actually used, which it never is. Macros in CLJS run on the CLJ side of things, therefore only the macro in utils.clj is only ever used. Leading to the expanded code having a reference to java.lang.Exception and leading to a runtime error if that catch was actually ever triggered.

My advice would be to get rid of the .utils ns entirely and add only this to the coercer ns. Note that (:ns &env) bit, which is only ever set during the CLJS macroexpansion phase and can therefore be used to emit code specifically for CLJS.

(defmacro invalid-on-throw!
  [& body]
  `(try
     ~@body
     (catch ~(if (:ns &env) :default `Exception) _#
       :exoscale.coax/invalid)))

The ns form can than be adjusted and the extra files removed. macrovich was never required to get this.

thheller avatar Sep 15 '25 13:09 thheller