--- Comment #25 from ag0ae...@gmail.com ---
(In reply to Walter Bright from comment #21)
> I suspect the core of a fix
> can be along the lines of detecting that an explicit import of bar.d is done
> using two different names in the same module.
That would fix a problem, but not this Bugzilla issue.
If you want to attack the issue at hand in the spec, then I suggest we get to
that before fixing related-but-not-identical cases. An attempt at amending the
spec is likely to reveal more interesting cases.
Also, so far we focused on accepts-invalid cases where we'd like DMD to throw
an error instead, but the lack of verification can also lead to wrong code when
the wrong module is accepted before the right one is attempted.
import std.stdio; /* Should import Phobos's std.stdio. */
writeln("Hello, world!"); /* Should print "Hello, world!". */
module pkg.std.stdio; /* NOTE: Not std.stdio. */
void writeln()(string s) /* Template makes for a shorter example. */
printf("Goodbye, cruel world!\n");
`cd pkg; dmd hello_world.d && ./hello_world; cd ..`:
Goodbye, cruel world!
Note that I have no custom module std.stdio. DMD incorrectly picks up
pkg.std.stdio as std.stdio, because it ignores the module declaration. Instead,
it should look at the module declaration, see that pkg.std.stdio is not
std.stdio, and then continue the search for the real std.stdio.
Maybe this too can be fixed without addressing the core problem of missing
verification (e.g. with a "best match" kind of thing). But I'm afraid this way
leads down a rabbit hole of special cases. In my opinion, it would be better to
have a clean cut, maybe with a deprecation period.