From e8afcb28a8f59fb530f7f8768d31b951ab882f1b Mon Sep 17 00:00:00 2001 From: Paul Berg Date: Mon, 28 Feb 2022 02:32:35 +0100 Subject: [PATCH] use name in source module when importing an aliased binding (#43291) Co-authored-by: Simeon David Schaub (cherry picked from commit 2338f5d3040ced10d69f4d15cca5fdca03364d9a) --- src/module.c | 2 +- test/syntax.jl | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/module.c b/src/module.c index 15624373d921f..e3b333bd142a5 100644 --- a/src/module.c +++ b/src/module.c @@ -485,7 +485,7 @@ static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *s, jl_s } } else { - jl_binding_t *nb = new_binding(s); + jl_binding_t *nb = new_binding(b->name); nb->owner = b->owner; nb->imported = (explici!=0); nb->deprecated = b->deprecated; diff --git a/test/syntax.jl b/test/syntax.jl index 61f10a9e4c52f..485f68c8a97e6 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2473,6 +2473,7 @@ end end module Mod2 +import ..Mod.x as x_from_mod const y = 2 end @@ -2513,6 +2514,11 @@ import .Mod.@mac as @m @test_throws ErrorException eval(:(import .Mod.func as @notmacro)) @test_throws ErrorException eval(:(using .Mod: @mac as notmacro)) @test_throws ErrorException eval(:(using .Mod: func as @notmacro)) + +import .Mod2.x_from_mod + +@test @isdefined(x_from_mod) +@test x_from_mod == Mod.x end import .TestImportAs.Mod2 as M2