ExplicitImports.jl icon indicating copy to clipboard operation
ExplicitImports.jl copied to clipboard

Name shadowing of an import when assigning it to a function argument causes spurious unused import diagnostics

Open KristofferC opened this issue 5 months ago • 3 comments

The following module causes a warning about an unused import but it is in fact used.

module M

using Base: wrap_string

function f(wrap_string = wrap_string("foo", UInt32(1)))
    print(wrap_string)
end

end

ExplicitImports.jl says:

  However, module Main.M has stale explicit imports for this 1 unused name:

    •  wrap_string is unused but it was imported from Base at M.jl:3:13

which is not true.

Happened for https://github.com/JuliaLang/Pkg.jl/blob/ffdb668b81658f1c46041fc921fa03d2fdb9527a/src/Registry/Registry.jl#L51 in the wild.

KristofferC avatar Jul 02 '25 09:07 KristofferC

This is my bad ad-hoc implementation of lowering/scoping; hoping switching to JuliaLowering for scope resolution can fix this. (Or maybe we can improve the existing implementation)

ericphanson avatar Jul 02 '25 11:07 ericphanson

this is the same as #129 in retrospect; I didn't realize it was a regression until that issue

ericphanson avatar Jul 21 '25 18:07 ericphanson

oops, it's a different issue, nvm

ericphanson avatar Jul 21 '25 18:07 ericphanson