diff --git a/src/module.c b/src/module.c index 63dff3ae6deb7..59731e8b5ba80 100644 --- a/src/module.c +++ b/src/module.c @@ -352,7 +352,7 @@ static jl_binding_t *jl_get_binding_(jl_module_t *m, jl_sym_t *var, modstack_t * // do a full import to prevent the result of this lookup // from changing, for example if this var is assigned to // later. - module_import_(m, b->owner, var, var, 0); + module_import_(m, b->owner, b->name, var, 0); return b; } return NULL; diff --git a/test/syntax.jl b/test/syntax.jl index 6ed3e7ca59ad7..795b69c9eea05 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2520,7 +2520,10 @@ end module Mod2 import ..Mod.x as x_from_mod +import ..Mod.x as x_from_mod2 const y = 2 + +export x_from_mod2 end import .Mod: x as x2 @@ -2565,6 +2568,12 @@ import .Mod2.x_from_mod @test @isdefined(x_from_mod) @test x_from_mod == Mod.x + +using .Mod2 + +@test_nowarn @eval x_from_mod2 +@test @isdefined(x_from_mod2) +@test x_from_mod2 == x_from_mod == Mod.x end import .TestImportAs.Mod2 as M2