Skip to content

Commit

Permalink
Fix implicit binding import for aliased bindings (#44827)
Browse files Browse the repository at this point in the history
`b->name` is used to lookup in `b->owner`, not `var`.

(cherry picked from commit dbe41d4)
  • Loading branch information
Pangoraw authored and KristofferC committed Dec 21, 2022
1 parent bfd1f5f commit 75a2bde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,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;
Expand Down
9 changes: 9 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,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
Expand Down Expand Up @@ -2535,6 +2538,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
Expand Down

0 comments on commit 75a2bde

Please sign in to comment.