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

@infiltrate stops working when Revise encounters parse errors #45

Closed
ExpandingMan opened this issue Sep 6, 2021 · 13 comments
Closed

@infiltrate stops working when Revise encounters parse errors #45

ExpandingMan opened this issue Sep 6, 2021 · 13 comments

Comments

@ExpandingMan
Copy link

Consider including the following script with includet

using Infiltrator

function test()
    ϕ = "what"
    @infiltrate
    sin(ϕ)
end

At first, this works as expected. Then, I cause a parsing error by changing "what" to "what'. Revise the throws the following error as expected

┌ Error: Failed to revise /home/expandingman/src/scrap.jl
│   exception =
│    LoadError: "incomplete: invalid string syntax"
│    Stacktrace:
│     [1] parse_source!(mod_exprs_sigs::OrderedCollections.OrderedDict{Module, OrderedCollections.OrderedDict{Revise.Relocat
bleExpr, Union{Nothing, Vector{Any}}}}, src::String, filename::String, mod::Module; mode::Symbol)
│       @ Revise ~/.julia/packages/Revise/OgnOk/src/parsing.jl:45
│    in expression starting at /home/expandingman/src/scrap.jl:7
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:709
┌ Warning: The running code does not match the saved version for the following files:
│
│   /home/expandingman/src/scrap.jl
│
│ If the error was due to evaluation order, it can sometimes be resolved by calling `Revise.retry()`.
│ Use Revise.errors() to report errors again. Only the first error in each file is shown.
│ Your prompt color may be yellow until the errors are resolved.
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:817

After fixing the string and recovering Revise with Revise.revise(), Revise is again working as expected. Infiltrator, however, does not and no longer breaks at @infiltrate even if I move it. I can confirm that Revise is working properly with print statements or whatever else, so this looks like purely an Infiltrator issue, though I can't rule out that something funky is happening in Revise that is stopping it from expanding the macro properly.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 6, 2021

Hm, interestingly enough I can't repro this issue. Just to be sure, you're on the latest version of both packages? Also, what Julia version are you on?

@ExpandingMan
Copy link
Author

Yup, latest tagged version of both packages. On Julia 1.6.2. This is using a startup.jl which can be found here.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 6, 2021

Very weird. With you startup file I get

λ j1 -q
julia> includet("test.jl")

julia> test()
Infiltrating test() at test.jl:5:

infil> 

0.9092974268256817

shell> cat test.jl
┌ Error: Failed to revise /home/pfitzseb/test.jl
│   exception =
│    LoadError: "incomplete: invalid string syntax"
│    Stacktrace:
│     [1] parse_source!(mod_exprs_sigs::OrderedCollections.OrderedDict{Module, OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}}, src::String, filename::String, mod::Module; mode::Symbol)
│       @ Revise ~/.julia/packages/Revise/OgnOk/src/parsing.jl:45
│    in expression starting at /home/pfitzseb/test.jl:8
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:709
┌ Warning: The running code does not match the saved version for the following files:
│ 
│   /home/pfitzseb/test.jl
│ 
│ If the error was due to evaluation order, it can sometimes be resolved by calling `Revise.retry()`.
│ Use Revise.errors() to report errors again. Only the first error in each file is shown.
│ Your prompt color may be yellow until the errors are resolved.
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:817
using Infiltrator

function test()
    ϕ = "what'
    @infiltrate
    sin(3)
end


julia> test()
Infiltrating test() at test.jl:5:

infil> 

0.9092974268256817

shell> cat test.jl
using Infiltrator

function test()
    ϕ = "what"
    @infiltrate
    sin(3)
end

julia> test()
Infiltrating test() at test.jl:5:

infil> 

0.1411200080598672

@ExpandingMan
Copy link
Author

ExpandingMan commented Sep 6, 2021

Ah! No, I think I figured it out, it's the combination of the two errors. Don't pass 3 to sin, pass \phi to deliberately get the error. I get the behavior you're showing from the code you shared. Try doing exactly what I originally posted.

Btw, for the hell of it I tried this in a fresh environment and it makes no difference.

I've also changed by startup.jl so I do using Revise outside of atreplinit as is suggested in more recent versions of the Revise docs. Again, this makes no difference.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 6, 2021

Still no luck:

λ j1 -q
julia> includet("test.jl")

julia> test()
Infiltrating test() at test.jl:5:

infil> 

ERROR: MethodError: no method matching sin(::String)
Closest candidates are:
  sin(::Float16) at math.jl:1159
  sin(::ComplexF16) at math.jl:1160
  sin(::Complex{T}) where T at complex.jl:831
  ...
Stacktrace:
 [1] test()
   @ Main ~/test.jl:6
 [2] top-level scope
   @ REPL[2]:1
 [3] top-level scope
   @ ~/.julia/dev/Infiltrator/src/Infiltrator.jl:473

shell> cat test.jl
┌ Error: Failed to revise /home/pfitzseb/test.jl
│   exception =
│    LoadError: "incomplete: invalid string syntax"
│    Stacktrace:
│     [1] parse_source!(mod_exprs_sigs::OrderedCollections.OrderedDict{Module, OrderedCollections.OrderedDict{Revise.RelocatableExpr, Union{Nothing, Vector{Any}}}}, src::String, filename::String, mod::Module; mode::Symbol)
│       @ Revise ~/.julia/packages/Revise/OgnOk/src/parsing.jl:45
│    in expression starting at /home/pfitzseb/test.jl:7
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:709
┌ Warning: The running code does not match the saved version for the following files:
│ 
│   /home/pfitzseb/test.jl
│ 
│ If the error was due to evaluation order, it can sometimes be resolved by calling `Revise.retry()`.
│ Use Revise.errors() to report errors again. Only the first error in each file is shown.
│ Your prompt color may be yellow until the errors are resolved.
└ @ Revise ~/.julia/packages/Revise/OgnOk/src/packagedef.jl:817
using Infiltrator

function test()
    ϕ = "what'
    @infiltrate
    sin(ϕ)
end


julia> test()
Infiltrating test() at test.jl:5:

infil> 

ERROR: MethodError: no method matching sin(::String)
Closest candidates are:
  sin(::Float16) at math.jl:1159
  sin(::ComplexF16) at math.jl:1160
  sin(::Complex{T}) where T at complex.jl:831
  ...
Stacktrace:
 [1] test()
   @ Main ~/test.jl:6
 [2] top-level scope
   @ REPL[4]:1
 [3] top-level scope
   @ ~/.julia/dev/Infiltrator/src/Infiltrator.jl:473

shell> cat test.jl
using Infiltrator

function test()
    ϕ = "what"
    @infiltrate
    sin(ϕ)
end


julia> test()
Infiltrating test() at test.jl:5:

infil> 

ERROR: MethodError: no method matching sin(::String)
Closest candidates are:
  sin(::Float16) at math.jl:1159
  sin(::ComplexF16) at math.jl:1160
  sin(::Complex{T}) where T at complex.jl:831
  ...
Stacktrace:
 [1] test()
   @ Main ~/test.jl:6
 [2] top-level scope
   @ REPL[6]:1
 [3] top-level scope
   @ ~/.julia/dev/Infiltrator/src/Infiltrator.jl:473

julia> Revise.revise()

julia> test()
Infiltrating test() at test.jl:5:

infil> 

ERROR: MethodError: no method matching sin(::String)
Closest candidates are:
  sin(::Float16) at math.jl:1159
  sin(::ComplexF16) at math.jl:1160
  sin(::Complex{T}) where T at complex.jl:831
  ...
Stacktrace:
 [1] test()
   @ Main ~/test.jl:6
 [2] top-level scope
   @ REPL[8]:1
 [3] top-level scope
   @ ~/.julia/dev/Infiltrator/src/Infiltrator.jl:473

@ExpandingMan
Copy link
Author

I'm incredibly confused... I can reproduce this quite reliably...

@ExpandingMan
Copy link
Author

The fact that I was able to achieve the same behavior you got when I changed the code a bit may suggest that this is a terrifying heisenbug... 😨

@pfitzseb
Copy link
Member

pfitzseb commented Sep 6, 2021

If you have time it would be useful to see what Revise's debug tools say to your situation: https://timholy.github.io/Revise.jl/stable/debugging/.

@ExpandingMan
Copy link
Author

I'm so confused... I can't even get Revise to capture any logs... I'm using Revise.debug_logger but it never gets populated...

Maybe there is something really whacked out about my Revise? At this point I don't know what that can be though, I'm just using latest tags, and now my startup.jl does exactly what Revise recommends. I'm pretty stumped.

@pfitzseb
Copy link
Member

pfitzseb commented Sep 7, 2021

Pinging @timholy in case he has any idea what's going on here.

@ExpandingMan
Copy link
Author

A small update on this, still experiencing this, it's still pretty annoying, and I still can't seem to figure out what's going on. However, so far it seems that when I do Revise.revise() it fixes the problem, which might suggest this is more of a Revise problem than an infiltrator problem. Perhaps it's failing to properly expand the macro when it gest updated? No idea

@ExpandingMan
Copy link
Author

Still can't isolate this but I've been dealing with this for quite a while now so I wanted to update with my experiences...

This still happens all the time and is very annoying, however, any time it does happen I can always fix it by explicitly calling Revise.revise(), so at least there is a quick workaround. It always starts happening after making an edit involving @infiltrate, not otherwise.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 8, 2024

I'll close this for now. Feel free to reopen this or open a new issues if you encounter the bug again.

@pfitzseb pfitzseb closed this as not planned Won't fix, can't repro, duplicate, stale Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants