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

include better at finding errors in line numbers than includet #437

Closed
pdeffebach opened this issue Feb 29, 2020 · 4 comments
Closed

include better at finding errors in line numbers than includet #437

pdeffebach opened this issue Feb 29, 2020 · 4 comments

Comments

@pdeffebach
Copy link

Tim,

I think we chatted about this on slack a while ago. I found an MWE. Maybe it isn't as minimal as it could be but I ran into the error again.

Here is a script with an error in it.

My workflow is just includet(q5.jl) and then calling everything via a short module name. Running Revise.errors() on this script, after it has been working, produces the following output. As you can see it's not obvious what the error is.

julia> Revise.errors()
┌ Warning: Due to a previously reported error, the running code does not match saved version for the following files:
│ 
│   /home/peterwd/Documents/Year 1 Semester 2/Metrics/Homework 2/src/q5.jl
│ 
│ Use Revise.errors() to report errors again.
└ @ Revise ~/.julia/packages/Revise/S7mrl/src/Revise.jl:639
┌ Error: Failed to revise /home/peterwd/Documents/Year 1 Semester 2/Metrics/Homework 2/src/q5.jl
│   exception =
│    LoadError: "extra token \"u_hat\" after end of expression"
│    Stacktrace:
│     [1] parse_source!(::OrderedCollections.OrderedDict{Module,OrderedCollections.OrderedDict{Revise.RelocatableExpr,Union{Nothing, Array{Any,1}}}}, ::String, ::String, ::Module) at /home/peterwd/.julia/packages/Revise/S7mrl/src/parsing.jl:45
│    in expression starting at /home/peterwd/Documents/Year 1 Semester 2/Metrics/Homework 2/src/q5.jl:3
└ @ Revise ~/.julia/packages/Revise/S7mrl/src/Revise.jl:590

Running include("q5.jl") gives a much more informative error message. It tells me my error is on line 87.

julia> include("src/q5.jl")
ERROR: LoadError: syntax: extra token "u_hat" after end of expression
Stacktrace:
 [1] top-level scope at /home/peterwd/Documents/Year 1 Semester 2/Metrics/Homework 2/src/q5.jl:87
 [2] include at ./boot.jl:328 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1105
 [4] include(::Module, ::String) at ./Base.jl:31
 [5] include(::String) at ./client.jl:424
 [6] top-level scope at REPL[8]:1
in expression starting at /home/peterwd/Documents/Year 1 Semester 2/Metrics/Homework 2/src/q5.jl:87

Hope this is helpful in improving Revise. love working with it.

@timholy
Copy link
Owner

timholy commented Mar 1, 2020

What Revise version are you on? With 2.5.3 (which includes #424) I get this:

julia> includet("q5.jl")
ERROR: LoadError: "extra token \"u_hat\" after end of expression"
Stacktrace:
 [1] parse_source!(::OrderedCollections.OrderedDict{Module,OrderedCollections.OrderedDict{Revise.RelocatableExpr,Union{Nothing, Array{Any,1}}}}, ::String, ::String, ::Module) at /home/tim/.julia/packages/Revise/SZ4ae/src/parsing.jl:45
 [2] parse_source!(::OrderedCollections.OrderedDict{Module,OrderedCollections.OrderedDict{Revise.RelocatableExpr,Union{Nothing, Array{Any,1}}}}, ::String, ::Module) at /home/tim/.julia/packages/Revise/SZ4ae/src/parsing.jl:27
 [3] parse_source at /home/tim/.julia/packages/Revise/SZ4ae/src/parsing.jl:10 [inlined]
 [4] #track#74(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol,Symbol},NamedTuple{(:define, :skip_include),Tuple{Bool,Bool}}}, ::typeof(Revise.track), ::Module, ::String) at /home/tim/.julia/packages/Revise/SZ4ae/src/Revise.jl:703
 [5] #track at ./none:0 [inlined]
 [6] includet(::Module, ::String) at /home/tim/.julia/packages/Revise/SZ4ae/src/Revise.jl:759
 [7] includet(::String) at /home/tim/.julia/packages/Revise/SZ4ae/src/Revise.jl:769
 [8] top-level scope at REPL[2]:1
in expression starting at /tmp/q5.jl:87

I'm not sure we really need all those Revise frames in the stacktrace, but at least it does point out the correct line.

@pdeffebach
Copy link
Author

Sorry, I should have been clearer. My error isn't on includet(), I usually do includet() when there is basically nothing in my script at all!

It happens when I make a typo in the midst of editing, calling Q5.main(), editing, calling Q5.main() etc. When it stops working because of a parsing error, Revise.errors() isn't that informative.

I just updated to 2.5.3 and the behavior is the same.

@timholy
Copy link
Owner

timholy commented Mar 1, 2020

If I replace the broken line with one that parses properly, load the package, and then switch back to the broken version, here's what I get:

julia> Q5.main()
┌ Error: Failed to revise /tmp/Q5.jl
│   exception =
│    LoadError: "extra token \"u_hat\" after end of expression"
│    Stacktrace:
│     [1] parse_source!(::OrderedCollections.OrderedDict{Module,OrderedCollections.OrderedDict{Revise.RelocatableExpr,Union{Nothing, Array{Any,1}}}}, ::String, ::String, ::Module) at /home/tim/.julia/packages/Revise/SZ4ae/src/parsing.jl:45
│    in expression starting at /tmp/Q5.jl:87
└ @ Revise ~/.julia/packages/Revise/SZ4ae/src/Revise.jl:590
┌ Warning: Due to a previously reported error, the running code does not match saved version for the following files:
│ 
│   /tmp/Q5.jl
│ 
│ Use Revise.errors() to report errors again.
└ @ Revise ~/.julia/packages/Revise/SZ4ae/src/Revise.jl:648

For me it's still showing line 87.

@timholy
Copy link
Owner

timholy commented Mar 28, 2020

I think this is fixed. Please provide more info if it is still a problem.

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

2 participants