Skip to content

using creates explicit bindings inconsistently #52817

Open
@LilithHafner

Description

@LilithHafner
julia> module M1 module M2 end end
Main.M1

julia> using .M1.M2

julia> using Statistics

julia> names(Main, imported=true)
5-element Vector{Symbol}:
 :Base
 :Core
 :M1
 :Main
 :Statistics

julia> module M3
           using Statistics
       end
Main.M3

julia> names(M3, imported=true)
1-element Vector{Symbol}:
 :M3

This is due to

julia/src/toplevel.c

Lines 771 to 775 in b354ce7

if (m == jl_main_module && name == NULL) {
// TODO: for now, `using A` in Main also creates an explicit binding for `A`
// This will possibly be extended to all modules.
import_module(m, u, NULL);
}

Which I think was added 7 years ago in #25256

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions