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

inaccurate line numbers in syntax errors #14

Open
stevengj opened this issue Sep 19, 2018 · 2 comments
Open

inaccurate line numbers in syntax errors #14

stevengj opened this issue Sep 19, 2018 · 2 comments

Comments

@stevengj
Copy link
Member

julia> softscope_include_string(Main, "begin\n3\nx ++++ y\nend")
ERROR: LoadError: syntax: "++" is not a unary operator
Stacktrace:
 [1] softscope_include_string(::Module, ::String, ::String) at /Users/stevenj/.julia/dev/SoftGlobalScope/src/SoftGlobalScope.jl:201
 [2] softscope_include_string(::Module, ::String) at /Users/stevenj/.julia/dev/SoftGlobalScope/src/SoftGlobalScope.jl:192
 [3] top-level scope at none:0
in expression starting at string:1

julia> include_string(Main, "begin\n3\nx ++++ y\nend")
ERROR: LoadError: syntax: "++" is not a unary operator
Stacktrace:
 [1] include_string(::Module, ::String, ::String) at ./loading.jl:1002
 [2] include_string(::Module, ::String) at ./loading.jl:1006
 [3] top-level scope at none:0
in expression starting at string:3

Notice that we are giving the syntax error at string:1 rather than at string:3.

@stevengj
Copy link
Member Author

stevengj commented Sep 19, 2018

In contrast, line numbers for ordinary exceptions seem to be tracked correctly, e.g. giving string:3 here:

julia> include_string(Main, "begin\n3\nerror(1)\nend")
ERROR: LoadError: 1
Stacktrace:
 [1] error(::Int64) at ./error.jl:42
 [2] top-level scope at string:3
 [3] include_string(::Module, ::String, ::String) at ./loading.jl:1002
 [4] include_string(::Module, ::String) at ./loading.jl:1006
 [5] top-level scope at none:0
in expression starting at string:1

julia> softscope_include_string(Main, "begin\n3\nerror(1)\nend")
ERROR: 1
Stacktrace:
 [1] error(::Int64) at ./error.jl:42
 [2] top-level scope at string:3
 [3] eval at ./boot.jl:319 [inlined]
 [4] softscope_include_string(::Module, ::String, ::String) at /Users/stevenj/.julia/dev/SoftGlobalScope/src/SoftGlobalScope.jl:206
 [5] softscope_include_string(::Module, ::String) at /Users/stevenj/.julia/dev/SoftGlobalScope/src/SoftGlobalScope.jl:192
 [6] top-level scope at none:0

However, it's still not wrapped in a LoadError, which is a separate issue.

@stevengj
Copy link
Member Author

Should no longer be an issue for Julia 1.5+ (#25).

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

No branches or pull requests

1 participant