From dec1727673797e0c5a1000299fca740f02038a53 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 7 Oct 2021 17:11:29 +0200 Subject: [PATCH] use the httable key instead of the binding name in jl_module_names --- src/module.c | 3 ++- test/syntax.jl | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/module.c b/src/module.c index 765f83498bac4..bb7d08e8bd5b4 100644 --- a/src/module.c +++ b/src/module.c @@ -833,9 +833,10 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported) (imported && b->imported) || (b->owner == m && !b->imported && (all || m == jl_main_module))) && (all || (!b->deprecated && !hidden))) { + 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 jl_array_grow_end(a, 1); //XXX: change to jl_arrayset if array storage allocation for Array{Symbols,1} changes: - jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)b->name); + jl_array_ptr_set(a, jl_array_dim0(a)-1, (jl_value_t*)in_module_name); } } } diff --git a/test/syntax.jl b/test/syntax.jl index 9bee6479e8e94..317ff39615298 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2493,6 +2493,10 @@ import .Mod: x as x2 @test x2 == 1 @test !@isdefined(x) +module_names = names(@__MODULE__; all=true, imported=true) +@test :x2 ∈ module_names +@test :x ∉ module_names + import .Mod2.y as y2 @test y2 == 2