[Issue 17589] Prevent local imports from hiding imported symbols
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Nov 22 03:31:13 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=17589
Bolpat <qs.il.paperinik at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |qs.il.paperinik at gmail.com
--- Comment #1 from Bolpat <qs.il.paperinik at gmail.com> ---
(In reply to timon.gehr from comment #0)
> Local imports should overload against less deeply nested imports. In this
> example, std.stdio.write and std.file.write should be treated as part of the
> same overload set within readAndLog. Otherwise, there is a hijacking risk.
You imported two `write` functions (overloaded sets) that weren't intended to
be used next to each other. Call compiles in both sets, so by the spec [1],
it's an ambiguous call. The spec does not say that "more local" imports shadow
"less local" imports for functions. While [2] says that imports can shadow
local definitions, [1] clearly says how overloaded sets are to be handled. At
best, [1] is correct and at worst, the spec contradicts itself.
[1] https://dlang.org/spec/function.html#overload-sets
[2] https://dlang.org/spec/module.html#scoped_imports
TL;DR: It should be an ambiguity error, nothing else.
--
More information about the Digitalmars-d-bugs
mailing list