Skip to content

imported name shadowed by field name #111

@kuszmaul

Description

@kuszmaul

Suppose I have a module

module Atest

hello() = "Hello, World!"

end # module

And another module

module Btest

using Atest: hello

struct Foo
    hello::String
    Foo() = new(hello())
end

end # module

Then I get

julia> using ExplicitImports, Btest
julia> print_explicit_imports(Btest)
  Module Btest is not relying on any implicit imports.

  However, module Btest has stale explicit imports for this 1 unused name:

    •  hello is unused but it was imported from Atest at
       /home/ubuntu/raicode-master/raicode/packages/Btest/src/Btest.jl:3:14

which is incorrect. hello is used in the constructor for Foo().

If I rename the field in Foo to, say hello2, then I don't get the warning

module Ctest

using Atest: hello

struct Foo
    hello2::String
    Foo() = new(hello())
end

end # module

tests ok:

julia> print_explicit_imports(Ctest)
  Module Ctest is not relying on any implicit imports.

julia>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscoping

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions