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

New macro calls defining functions are incorrectly revised #792

Closed
Keluaa opened this issue Jan 4, 2024 · 1 comment · Fixed by #794
Closed

New macro calls defining functions are incorrectly revised #792

Keluaa opened this issue Jan 4, 2024 · 1 comment · Fixed by #794

Comments

@Keluaa
Copy link

Keluaa commented Jan 4, 2024

Using Revise v3.5.12 and LoweredCodeUtils v2.4.3 on Julia 1.10:

julia> using Revise

julia> rlogger = Revise.debug_logger();

julia> macro my_macro(name)
           return esc(quote
               function $name end
               println($name)
           end)
       end
@my_macro (macro with 1 method)

julia> file = tempname();

julia> open(file, "w") do f; println(f, "@my_macro f1") end

julia> includet(file); f1
f1
f1 (generic function with 0 methods)

julia> open(file, "a") do f; println(f, "@my_macro f2") end

julia> f2
ERROR: UndefVarError: `f2` not defined

julia> rlogger.logs
1-element Vector{Revise.LogRecord}:
 Revise.LogRecord(Debug, Eval, Action, Revise_9147188b, "C:\Users\lucbr\.julia\packages\Revise
\RZlAf\src\packagedef.jl", 325, (time=1.704399665147e9, deltainfo=(Main, quote
    #= C:\Users\lucbr\AppData\Local\Temp\jl_d2z6zAf8Vk:2 =#
    #= C:\Users\lucbr\AppData\Local\Temp\jl_d2z6zAf8Vk:2 =# @my_macro f2
end)))

I was able to replicate the issue with Julia 1.9.
With Revise v3.5.10 and LoweredCodeUtils v2.4.1, f2 is correctly defined. Using any versions above those results in other errors. The latest ones (v3.5.12 and v2.4.3) are the only one for which it doesn't throw and doesn't work.

@timholy
Copy link
Owner

timholy commented Jan 6, 2024

Thanks for the nice clean report!

timholy added a commit that referenced this issue Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants