Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finer-grained location info for error messages, strack traces: line number, column number range #53090

Open
nsajko opened this issue Jan 28, 2024 · 2 comments
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:error handling Handling of exceptions by Julia or the user domain:error messages Better, more actionable error messages parser Language parsing and surface syntax

Comments

@nsajko
Copy link
Contributor

nsajko commented Jan 28, 2024

a.jl:

1 +
2 +
3 +
error() +
5

b.jl:

1 + 2 + 3 + 4 + error() + 5

REPL session:

julia> include("a.jl")  # It'd be nice to get a more accurate line number here, i.e., "4" instead of "1"
ERROR: LoadError: 
Stacktrace:
 [1] error()
   @ Base ./error.jl:44
 [2] top-level scope
   @ /tmp/asdoi98uz/a.jl:1
 [3] include(fname::String)
   @ Main ./sysimg.jl:38
 [4] top-level scope
   @ REPL[1]:1
in expression starting at /tmp/asdoi98uz/a.jl:1

julia> include("b.jl")  # It'd be nice to get a column number range here for the offending call, `error()`
ERROR: LoadError: 
Stacktrace:
 [1] error()
   @ Base ./error.jl:44
 [2] top-level scope
   @ /tmp/asdoi98uz/b.jl:1
 [3] include(fname::String)
   @ Main ./sysimg.jl:38
 [4] top-level scope
   @ REPL[2]:1
in expression starting at /tmp/asdoi98uz/b.jl:1

julia> versioninfo()
Julia Version 1.11.0-DEV.1389
Commit ecc14ca3888 (2024-01-27 15:45 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 3 5300U with Radeon Graphics
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, znver2)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

Related issues: #33735, #38531, #50834

@nsajko nsajko added domain:error handling Handling of exceptions by Julia or the user parser Language parsing and surface syntax compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:error messages Better, more actionable error messages labels Jan 28, 2024
@nsajko nsajko changed the title finer-grained location info for error messages, strack traces: line number, column number finer-grained location info for error messages, strack traces: line number, column number range Jan 28, 2024
@Keno
Copy link
Member

Keno commented Jan 29, 2024

The way to do this is to change all source locations to byte offset and use the parser tree from the new parser to get more info lazily.

@timholy
Copy link
Sponsor Member

timholy commented Jan 29, 2024

Agreed. With the new parser, planned work on lowering, and #52415, on the horizon we can finally see a good solution to a lot of significant usability issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:error handling Handling of exceptions by Julia or the user domain:error messages Better, more actionable error messages parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants