This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # beginners (12)
- # calva (18)
- # cider (1)
- # cljs-dev (29)
- # clojure (99)
- # clojure-uk (18)
- # clojurescript (10)
- # clojureverse-ops (2)
- # cursive (7)
- # emacs (10)
- # fulcro (42)
- # graphql (36)
- # joker (1)
- # juxt (28)
- # mount (2)
- # other-languages (2)
- # pathom (1)
- # portkey (3)
- # re-frame (50)
- # shadow-cljs (42)
- # spacemacs (4)
- # sql (6)
- # yada (6)
Is there any way to debug compiled classes created by
compile function from a CLJ source?
I see some magic - a function calls another function with a not-nil argument, and the callee still receives nil. I see that the call stack includes 2 levels for each function call, so there must be something fishy going on in there.
Here's a piece of code of interest:
When the current line is the very first one,
(defn write "Writes a value to a transit writer." [^Writer writer o] (.write ^com.cognitect.transit.Writer (.w writer) o))
writeris not null. But as soon as I step into , it becomes null for no apparent reason.
Ahh, the value there is not actually null - the NPE is in the
.write function, a step further.
But why does the debugger report null here? I'm in the debug mode, so locals should not be cleared. Let alone locals in the current frame.
Maybe you got bit by https://clojure.org/reference/compilation#_locals_clearing ?
-Dclojure.compiler.disable-locals-clearing=true in my
:jvm-opts, and the corresponding button in the debug REPL is pushed in, so that shouldn't be it.
@U2FRKM4TW That definitely sounds like locals clearing. Note that locals clearing is a compile flag, it has to be set when you compile your code. If you’re loading from source then having it set in your runtime is sufficient since your code will be compiled when it’s loaded, but if you’re AOT compiling you’ll have to either set the flag before compiling or re-evaluate your code (i.e. re-send the file to the REPL) to have it be recompiled taking the flag into account.