simonster / Reexport.jl

Julia macro for re-exporting one module from another
Other
161 stars 19 forks source link

importall A; @reexport using A causes warning #1

Closed lendle closed 10 years ago

lendle commented 10 years ago
module A end

module B
    using Reexport
    importall A
    @reexport using A
end
julia> using B
Warning: using B.A in module Main conflicts with an existing identifier.

The only reason I'm using using A is to also @reexport everything. I tried changing the macro to allow for importall so I could just do @reexport importall A once, but the warning still showed up.

simonster commented 10 years ago

It looks like the problem is that importall A and import A actually create a new binding for A in the local scope, whereas using doesn't. You don't need Reexport.jl to see this:

module A end
module B
    importall A
    export A
end
using B

B.A === A, but these are separate bindings. I'm not sure if there is a good reason for this behavior, but we could avoid the warning if we don't export the module itself.