Skip to content

Commit 8d82176

Browse files
authored
use the httable key instead of the binding name in jl_module_names (#42532)
1 parent ad607a2 commit 8d82176

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
@@ -833,9 +833,10 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
833833
(imported && b->imported) ||
834834
(b->owner == m && !b->imported && (all || m == jl_main_module))) &&
835835
(all || (!b->deprecated && !hidden))) {
836+
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
836837
jl_array_grow_end(a, 1);
837838
//XXX: change to jl_arrayset if array storage allocation for Array{Symbols,1} changes:
838-
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)b->name);
839+
jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)in_module_name);
839840
}
840841
}
841842
}

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)