Skip to content

Commit 0a50e14

Browse files
PangorawKristofferC
authored andcommitted
use the httable key instead of the binding name in jl_module_names (#42532)
(cherry picked from commit 8d82176)
1 parent d0495f8 commit 0a50e14

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,10 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
818818
(imported && b->imported) ||
819819
(b->owner == m && !b->imported && (all || m == jl_main_module))) &&
820820
(all || (!b->deprecated && !hidden))) {
821+
jl_sym_t *in_module_name = (jl_sym_t*)table[i-1]; // the name in the module may not be b->name, use the httable key instead
821822
jl_array_grow_end(a, 1);
822823
//XXX: change to jl_arrayset if array storage allocation for Array{Symbols,1} changes:
823-
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)b->name);
824+
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)in_module_name);
824825
}
825826
}
826827
}

test/syntax.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,6 +2473,10 @@ import .Mod: x as x2
24732473
@test x2 == 1
24742474
@test !@isdefined(x)
24752475

2476+
module_names = names(@__MODULE__; all=true, imported=true)
2477+
@test :x2 module_names
2478+
@test :x module_names
2479+
24762480
import .Mod2.y as y2
24772481

24782482
@test y2 == 2

0 commit comments

Comments
 (0)