-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Using @sync
from a package macro fails when the same result works in the REPL
#28775
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
Comments
It looks like an issue with the escape in Lines 241 to 243 in f6c48eb
julia> macroexpand(Main, :(Tester.@tester()))
quote
#= REPL[8]:4 =#
begin
#= task.jl:243 =#
let Main.Tester.:(##sync#72) = (Base.Any)[]
#= task.jl:244 =#
#12#v = for #11#i = 1:5
#= REPL[8]:5 =#
(Main.Tester.println)(#11#i)
end
#= task.jl:245 =#
(Base.sync_end)(Main.Tester.:(##sync#72))
#= task.jl:246 =#
#12#v
end
end
end |
Note that this is a regression from v0.6: the broadcast code from which this was found used to work. |
Hygiene for macros inside macros feels impossible to do correctly now. Perhaps it was impossible before as well, but it seemed to generally work as you expected. Ref #22985 |
I had a similar problem (1.5.0-DEV). The only solution I've found was to aggressively use interpolation: julia> macro sync_wrapper_hygiene(ex)
quote
@sync begin
$(esc(ex))
end
end
end
@sync_wrapper_hygiene (macro with 1 method)
julia> macro sync_wrapper_interpolation(ex)
quote
$Base.@sync begin
$ex
end
end |> esc
end
@sync_wrapper_interpolation (macro with 1 method)
julia> @sync_wrapper_hygiene nothing
ERROR: syntax: invalid let syntax
Stacktrace:
[1] top-level scope at REPL[3]:1
julia> @sync_wrapper_interpolation nothing # works (It breaks even within REPL, though.) |
This is likely just a bug in the macroexpand.scm code. It's got a buggy re-implementation of resolve-scopes, and it is simply unaware of how to handle
|
Maybe this is simpler than I think, but ChrisRackauckas/ParallelDataTransfer.jl#14 seems to demonstrate that using
@sync
from outside theMain
module gives an issue withlet
. MWE:throws
The text was updated successfully, but these errors were encountered: