Skip to content

Commit 94bc7bf

Browse files
PangorawKristofferC
authored andcommitted
Fix implicit binding import for aliased bindings (#44827)
`b->name` is used to lookup in `b->owner`, not `var`. (cherry picked from commit dbe41d4)
1 parent a82257d commit 94bc7bf

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/module.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ static jl_binding_t *jl_get_binding_(jl_module_t *m, jl_sym_t *var, modstack_t *
328328
// do a full import to prevent the result of this lookup
329329
// from changing, for example if this var is assigned to
330330
// later.
331-
module_import_(m, b->owner, var, var, 0);
331+
module_import_(m, b->owner, b->name, var, 0);
332332
return b;
333333
}
334334
return NULL;

test/syntax.jl

+9
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,10 @@ end
24902490

24912491
module Mod2
24922492
import ..Mod.x as x_from_mod
2493+
import ..Mod.x as x_from_mod2
24932494
const y = 2
2495+
2496+
export x_from_mod2
24942497
end
24952498

24962499
import .Mod: x as x2
@@ -2535,6 +2538,12 @@ import .Mod2.x_from_mod
25352538

25362539
@test @isdefined(x_from_mod)
25372540
@test x_from_mod == Mod.x
2541+
2542+
using .Mod2
2543+
2544+
@test_nowarn @eval x_from_mod2
2545+
@test @isdefined(x_from_mod2)
2546+
@test x_from_mod2 == x_from_mod == Mod.x
25382547
end
25392548

25402549
import .TestImportAs.Mod2 as M2

0 commit comments

Comments
 (0)