Skip to content

Commit b825b2d

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 b6f1cbc commit b825b2d

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
@@ -826,9 +826,10 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
826826
(imported && b->imported) ||
827827
(b->owner == m && !b->imported && (all || m == jl_main_module))) &&
828828
(all || (!b->deprecated && !hidden))) {
829+
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
829830
jl_array_grow_end(a, 1);
830831
//XXX: change to jl_arrayset if array storage allocation for Array{Symbols,1} changes:
831-
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)b->name);
832+
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)in_module_name);
832833
}
833834
}
834835
}

test/syntax.jl

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

2496+
module_names = names(@__MODULE__; all=true, imported=true)
2497+
@test :x2 module_names
2498+
@test :x module_names
2499+
24962500
import .Mod2.y as y2
24972501

24982502
@test y2 == 2

0 commit comments

Comments
 (0)