Warning about variable conflict from module export?

aaoo
Wed, 25 Sep 2024 01:45:25 +0000
New to Julia

This may not work in v"1.10", got a warning on name conflicts.

julia> module Foo
           x = 1
           y = 2

           for n in names(@__MODULE__; all=true)
               if Base.isidentifier(n) && n ∉ (Symbol(@__MODULE__), :eval, :include)
                   @eval export $n
               end
           end
       end
Main.Foo

julia> using .Foo

julia> x
1

julia> module Foo
           x = 1000000
           y = 2

           for n in names(@__MODULE__; all=true)
               if Base.isidentifier(n) && n ∉ (Symbol(@__MODULE__), :eval, :include)
                   @eval export $n
               end
           end
       end
WARNING: replacing module Foo.
Main.Foo

julia> using .Foo
WARNING: using Foo.x in module Main conflicts with an existing identifier.

julia> x
1

3 posts - 2 participants