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

@eval interpolation broken inside @require block #86

Open
marius311 opened this issue Jun 5, 2020 · 1 comment
Open

@eval interpolation broken inside @require block #86

marius311 opened this issue Jun 5, 2020 · 1 comment

Comments

@marius311
Copy link

A MWE with Julia 1.4.2 and Requires v1.0.1:

julia> using Requires

julia> @require Requires="ae029012-a4dd-5104-9daa-d747884805df" begin
           x = 2
           @eval $x
       end
ERROR: UndefVarError: x not defined
@mcabbott
Copy link

I think this is a more general problem with macros being expanded before the package is loaded, I've run into it when e.g. calling Zygote.@adjoint within a block. Moving the code into a file is a work-around:

julia> using Requires

shell> cat test.jl
x = 2
@eval $x

julia> @require Requires="ae029012-a4dd-5104-9daa-d747884805df" begin
           include("test.jl")
       end
2

julia> @require Requires="ae029012-a4dd-5104-9daa-d747884805df" begin
           x = 2
           @eval $x
       end
ERROR: UndefVarError: x not defined

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