[Issue 15086] import doesn't verify module declaration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 13 18:32:58 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=15086

--- Comment #8 from Andrei Alexandrescu <andrei at erdani.com> ---
I think at the least we can do a vastly better job at issuing error messages.
Per the discussion in :

===
This error occurs becase the module foo/bar.d is being loaded twice with 2
different names. The first time it is loaded because it is given on the command
line, and since it has no module declaration, the compiler gives it the name
bar. But then the module gets imported with the name foo.bar, however, the
compiler cannot change the name of the module and all existing reference to it
so an error must be asserted. 
[...]
[this bug is allowing] weird abuses which in my opinion have no utility and
only serve to add confusion to the module system.
===

I do agree matters can be confusing especially during project organization and
reorganization. I've done my share of head scratching. I think we'd go a long
way with better error messages (e.g. explaining the matter with two access
paths above), and better online documentation for the module directive.

--


More information about the Digitalmars-d-bugs mailing list