Skip to content

Commit 6ac3ed3

Browse files
remove warning from c when binding is ambiguous
1 parent a007e80 commit 6ac3ed3

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

doc/src/manual/modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ julia> module B
283283
B
284284
```
285285

286-
The statement `using .A, .B` works, but when you try to call `f`, you get a warning
286+
The statement `using .A, .B` works, but when you try to call `f`, you get an error with a hint
287287

288288
```jldoctest module_manual
289289
julia> using .A, .B
290290
291291
julia> f
292-
WARNING: both B and A export "f"; uses of it in module Main must be qualified
293292
ERROR: UndefVarError: `f` not defined in `Main`
293+
Hint: It looks like two or more modules export different bindings with this name, resulting in ambiguity. Try explicitly importing it from a particular module, or qualifying the name with the module it should come from.
294294
```
295295

296296
Here, Julia cannot decide which `f` you are referring to, so you have to make a choice. The following solutions are commonly used:

src/module.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,21 +423,8 @@ static jl_binding_t *using_resolve_binding(jl_module_t *m JL_PROPAGATES_ROOT, jl
423423
jl_ptr_kind_union_t tempb_pku = jl_atomic_load_relaxed(&tempbpart->restriction);
424424
assert(decode_restriction_kind(tempb_pku) == BINDING_KIND_GLOBAL || decode_restriction_kind(tempb_pku) == BINDING_KIND_DECLARED || jl_bkind_is_some_constant(decode_restriction_kind(tempb_pku)));
425425
(void)tempb_pku;
426-
if (bpart != NULL && !tempb->deprecated && !b->deprecated && !eq_bindings(tempbpart, b, jl_current_task->world_age)) {
427-
if (warn) {
428-
// set usingfailed=1 to avoid repeating this warning
429-
// the owner will still be NULL, so it can be later imported or defined
430-
tempb = jl_get_module_binding(m, var, 1);
431-
tempbpart = jl_get_binding_partition(tempb, jl_current_task->world_age);
432-
jl_atomic_store_release(&tempbpart->restriction, encode_restriction(NULL, BINDING_KIND_FAILED));
433-
jl_printf(JL_STDERR,
434-
"WARNING: both %s and %s export \"%s\"; uses of it in module %s must be qualified\n",
435-
jl_symbol_name(owner->name),
436-
jl_symbol_name(imp->name), jl_symbol_name(var),
437-
jl_symbol_name(m->name));
438-
}
426+
if (bpart != NULL && !tempb->deprecated && !b->deprecated && !eq_bindings(tempbpart, b, jl_current_task->world_age))
439427
return NULL;
440-
}
441428
if (owner == NULL || !tempb->deprecated) {
442429
owner = imp;
443430
b = tempb;

0 commit comments

Comments
 (0)