Skip to content

Commit 23ce8ab

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 8abef03 commit 23ce8ab

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static jl_binding_t *jl_get_binding_(jl_module_t *m, jl_sym_t *var, modstack_t *
352352
// do a full import to prevent the result of this lookup
353353
// from changing, for example if this var is assigned to
354354
// later.
355-
module_import_(m, b->owner, var, var, 0);
355+
module_import_(m, b->owner, b->name, var, 0);
356356
return b;
357357
}
358358
return NULL;

test/syntax.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,10 @@ end
25202520

25212521
module Mod2
25222522
import ..Mod.x as x_from_mod
2523+
import ..Mod.x as x_from_mod2
25232524
const y = 2
2525+
2526+
export x_from_mod2
25242527
end
25252528

25262529
import .Mod: x as x2
@@ -2565,6 +2568,12 @@ import .Mod2.x_from_mod
25652568

25662569
@test @isdefined(x_from_mod)
25672570
@test x_from_mod == Mod.x
2571+
2572+
using .Mod2
2573+
2574+
@test_nowarn @eval x_from_mod2
2575+
@test @isdefined(x_from_mod2)
2576+
@test x_from_mod2 == x_from_mod == Mod.x
25682577
end
25692578

25702579
import .TestImportAs.Mod2 as M2

0 commit comments

Comments
 (0)