Skip to content

Commit e9e5450

Browse files
Pangorawsimeonschaub
authored andcommitted
use name in source module when importing an aliased binding (#43291)
Co-authored-by: Simeon David Schaub <[email protected]> (cherry picked from commit 2338f5d)
1 parent bf3e57d commit e9e5450

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static void module_import_(jl_module_t *to, jl_module_t *from, jl_sym_t *s, jl_s
490490
}
491491
}
492492
else {
493-
jl_binding_t *nb = new_binding(s);
493+
jl_binding_t *nb = new_binding(b->name);
494494
nb->owner = b->owner;
495495
nb->imported = (explici!=0);
496496
nb->deprecated = b->deprecated;

test/syntax.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,7 @@ end
24932493
end
24942494

24952495
module Mod2
2496+
import ..Mod.x as x_from_mod
24962497
const y = 2
24972498
end
24982499

@@ -2533,6 +2534,11 @@ import .Mod.@mac as @m
25332534
@test_throws ErrorException eval(:(import .Mod.func as @notmacro))
25342535
@test_throws ErrorException eval(:(using .Mod: @mac as notmacro))
25352536
@test_throws ErrorException eval(:(using .Mod: func as @notmacro))
2537+
2538+
import .Mod2.x_from_mod
2539+
2540+
@test @isdefined(x_from_mod)
2541+
@test x_from_mod == Mod.x
25362542
end
25372543

25382544
import .TestImportAs.Mod2 as M2

0 commit comments

Comments
 (0)