gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
230 stars 21 forks source link

stacktraces point to the temp snail file instead of the source file after evaluating top-level-form or region #28

Closed orialb closed 2 years ago

orialb commented 4 years ago

Consider the following code:

function foo()
    throw("oh oh something went wrong")
end

And evaluate foo with julia-snail-send-top-level-form.

The resulting stack trace when running in the REPL is:

julia> foo()
ERROR: "oh oh something went wrong"
Stacktrace:
 [1] foo() at /var/folders/lw/pcgd7z3n00bdlc8_jncyqw1m0000gn/T/julia-tmpBhAl8A:2
 [2] top-level scope at REPL[1]:1

This can make it hard to figure out where is the error coming from in a more complicated situation (for example line numbers don't correspond to those in the actual source file).

I don't know if there is a way to somehow track the correct source file when evaluating code in the way snail does or how complicated it would be to do so. Maybe one can look into Revise for inspiration as it seems that there stack-traces point to the correct place after re-evaluation of the code (but maybe the re-evaluation mechanism is too different than Snail, I don't know).

gcv commented 4 years ago

Yes, I know about this problem. I researched it a little bit a while ago, and found some Julia-internal metadata with function file and line number. I don't remember why I didn't just overwrite it with known correct entries after a top-level form has been loaded. It's definitely worth another look.

gcv commented 2 years ago

I tried to fix this. Commit 4c826e8 takes care of locations for xref purposes, but not for stack traces. I don't know enough about Julia internals to solve this, and posted a question on Discourse: https://discourse.julialang.org/t/updating-the-location-of-a-method-definition/65247/1

orialb commented 2 years ago

thanks for looking into this!

gcv commented 2 years ago

Thanks to a great suggestion on Discourse, I think I finally fixed this: 7bdfef8.