Skip to content

Jump to the frame's own source in stacktraces#4066

Merged
bbatsov merged 1 commit into
masterfrom
fix-3157-stacktrace-anon-fn
Jul 1, 2026
Merged

Jump to the frame's own source in stacktraces#4066
bbatsov merged 1 commit into
masterfrom
fix-3157-stacktrace-anon-fn

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 1, 2026

Copy link
Copy Markdown
Member

Closes #3157.

Clicking a stack frame for a top-level anonymous function - the shape deftest expands to - jumped to clojure.core/fn instead of your code. cider-stacktrace-navigate resolved the frame's .../fn var via cider-var-info, which resolves fn to clojure.core/fn and lets its file/line override the frame's own correct location.

I reproduced it against current orchard (orchard.stacktrace/analyze on the exact repro): the anonymous-fn frame now comes back with a populated :file-url (an absolute file: path) and an accurate :line - unlike the 2022 dump in the issue where :file-url was nil. So the backend already hands us everything needed; the client was just throwing it away (it didn't even capture file-url off the frame).

The fix: prefer the frame's own file-url + line and skip the var re-resolution. Frames without a file-url (REPL evals / NO_SOURCE_FILE) keep the existing var/class fallback with its line-shift. Validated on a multi-line fn that the frame's line points at the throwing line, so no line-shift is needed on the file-url path. Unit tests cover both paths.

Clicking a stack frame for a top-level anonymous function (the deftest
pattern) jumped to `clojure.core/fn': `cider-stacktrace-navigate' resolved
the frame's `.../fn' var via `cider-var-info', which resolves `fn' to
`clojure.core/fn' and clobbers the frame's own (correct) location.

The middleware now populates each frame's file-url with a resolved
absolute path and an accurate line (verified against current orchard), so
prefer that directly and skip the var resolution. Frames without a
file-url (e.g. REPL evaluations with NO_SOURCE_FILE) keep the old var/class
fallback. The frame button now carries file-url for this.
@bbatsov bbatsov force-pushed the fix-3157-stacktrace-anon-fn branch from 5f392c3 to 4b0e113 Compare July 1, 2026 13:12
@bbatsov bbatsov merged commit 8bda52a into master Jul 1, 2026
13 checks passed
@bbatsov bbatsov deleted the fix-3157-stacktrace-anon-fn branch July 1, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cider jumps to clojure.core/fn as source of stack frames for top level anonymous functions

1 participant