Open owenRiddy opened 1 year ago
I investigated this issue and it seems to come down to the behaviour of clojure.walk/macroexpand-all
. Eg,
(clojure.walk/macroexpand-all
'(letfn [(dummy [] true)]
(d)))
; => (letfn* [dummy (fn* dummy ([] true))] (nil))
; Clearly not how the macro actually expands when evaluated
I assume this is some interaction with special forms. It makes spectre
-related operations challenging to debug with letfn
functions.
I'm not sure how this is best fixed. Since macroexpand-all
is not guaranteed to be reliable it may be prudent to document this behaviour at https://docs.cider.mx/cider/debugging/debugger.html as a caveat and if possible provide some sort of #dbg like form that does not macroexpand. I don't need to dig in to the specter internals.
Expected behavior
Say I have this code (which is a test case developed from a stacktrace in Spectre which does similar things but more reasonably):
I expect to be able to instrument that function in the debugger:
Actual behavior
A stacktrace.
It seems that
clojure.walk/macroexpand-all
doesn't set up bindings in the same way as a real evaluation would.Steps to reproduce the problem
This code reproduces the stacktrace.
Environment & Version information
Emacs (Debian testing).
CIDER version information
Lein / Clojure CLI version
Project did have the following deps while constructing the test case, but probably shouldn't be needed to reproduce behavior:
Emacs version
28.2
Operating system
Debian Testing.
JDK distribution