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

The Macro "@reexport" Fails in Modules Declared with "baremodule" #32

Closed
Acmion opened this issue Aug 24, 2021 · 1 comment · Fixed by #33
Closed

The Macro "@reexport" Fails in Modules Declared with "baremodule" #32

Acmion opened this issue Aug 24, 2021 · 1 comment · Fixed by #33

Comments

@Acmion
Copy link

Acmion commented Aug 24, 2021

Decorating your modules with baremodule (which does not import Base by default) will cause @reexport to fail with the following error:

ERROR: LoadError: UndefVarError: names not defined
Stacktrace:
 [1] top-level scope
   @ actual\b.jl:3
 [2] include(m::Module, fname::String)
   @ Core .\boot.jl:358
 [3] top-level scope
   @ none:1
in expression starting at actual/b.jl:3

Examples

The following code works:

module b
    using Reexport
    @reexport using BenchmarkTools
end

The following code does not work:

baremodule b
    using Reexport
    @reexport using BenchmarkTools
end

Potential Solution
In Reexport.jl/src/Reexport.jl you could refer to Reexport.Base.names rather than to names. This will work with a relatively high probability, since the module Reexport would have to be imported in each context where it is to be used and as such we can qualify Base using the module name.

However, this approach could still fail if someone would import this module followingly:

using Reexport as Re

I suppose that the root cause of this problem is the eval statement in the expression returned by the @reexport macro. Maybe it would be easier to fix the problem there?

@ararslan
Copy link
Collaborator

Thanks for the report! I have a fix in #33.

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

Successfully merging a pull request may close this issue.

2 participants