Skip to content

Commit

Permalink
fix #26267, regression in names with imported=false (#26293)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Mar 2, 2018
1 parent d1f2678 commit 275b105
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ JL_DLLEXPORT jl_value_t *jl_module_names(jl_module_t *m, int all, int imported)
int hidden = jl_symbol_name(b->name)[0]=='#';
if ((b->exportp ||
(imported && b->imported) ||
((b->owner == m) && (all || m == jl_main_module))) &&
(b->owner == m && !b->imported && (all || m == jl_main_module))) &&
(all || (!b->deprecated && !hidden))) {
jl_array_grow_end(a, 1);
//XXX: change to jl_arrayset if array storage allocation for Array{Symbols,1} changes:
Expand Down
13 changes: 11 additions & 2 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,23 @@ static jl_method_instance_t *method_instance_for_thunk(jl_code_info_t *src, jl_m
static void import_module(jl_module_t *m, jl_module_t *import)
{
jl_sym_t *name = import->name;
jl_binding_t *b;
if (jl_binding_resolved_p(m, name)) {
jl_binding_t *b = jl_get_binding(m, name);
b = jl_get_binding(m, name);
if (b->owner != m || (b->value && b->value != (jl_value_t*)import)) {
jl_errorf("importing %s into %s conflicts with an existing identifier",
jl_symbol_name(name), jl_symbol_name(m->name));
}
}
jl_set_const(m, name, (jl_value_t*)import);
else {
b = jl_get_binding_wr(m, name, 1);
b->imported = 1;
}
if (!b->constp) {
b->value = (jl_value_t*)import;
b->constp = 1;
jl_gc_wb(m, (jl_value_t*)import);
}
}

// replace Base.X with top-level X
Expand Down
9 changes: 9 additions & 0 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,12 @@ typeparam(::Type{T}, a::AbstractArray{T}) where T = 2
@test typeparam(Int, rand(Int, 2)) == 2

end

# issue #26267
module M26267
import Test
foo(x) = x
end
@test !(:Test in names(M26267, all=true, imported=false))
@test :Test in names(M26267, all=true, imported=true)
@test :Test in names(M26267, all=false, imported=true)

0 comments on commit 275b105

Please sign in to comment.