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`.
  • Loading branch information
Pangoraw authored and pull[bot] committed Jun 9, 2022
1 parent 2da0a77 commit 28b4286
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 @@ -352,7 +352,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 @@ -2531,7 +2531,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 @@ -2576,6 +2579,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 28b4286

Please sign in to comment.