julia icon indicating copy to clipboard operation
julia copied to clipboard

don't warn on `using Foo: _` as syntax for loading packages only for side-effects

Open ericphanson opened this issue 6 months ago • 0 comments

it would be nice if one could do

using ForwardDiff: _

That actually works and does load the module on 1.11, but it gives a warning:

WARNING: could not import ForwardDiff._ into Main

on nightly it gives a different warning:

julia> "ForwardDiff" in string.(collect(values(Base.loaded_modules)))
false

julia> using ForwardDiff: _
WARNING: Imported binding ForwardDiff._ was undeclared at import time during import to Main.

julia> "ForwardDiff" in string.(collect(values(Base.loaded_modules)))
true

but again still works.

One can do import ForwardDiff as _ but some style guides recommend only using. You can spell it using ForwardDiff: ForwardDiff as _ but the repetition isn't as nice.

Originally posted by @ericphanson in https://github.com/JuliaLang/julia/pull/58665#discussion_r2134226571

ericphanson avatar Jun 07 '25 23:06 ericphanson