Bug 7122 – [module] compiler fails to handle import of renamed module
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-12-16T21:19:00Z
Last change time
2013-01-09T07:07:42Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2011-12-16T21:19:16Z
---- a0.d ----
module foo;
---- a1.d ----
module a1;
import a0;
--------------
dmd -lib a0.d a1.d
--------------
a1.d(2): Error: module foo from file a0.d conflicts with another module foo from file a0.d
--------------
The compiler should detect this import as an already known module.
This is important when splitting a module into declaration and
definition when the defining file should be located in a path
that doesn't match the module name.
Comment #1 by andrej.mitrovich — 2012-12-27T08:57:53Z
You can use whatever filename you want but you have to use the name in the module declaration when importing. See also Issue 4479
Comment #2 by code — 2013-01-08T14:50:24Z
Then per module compilation can't work.
dmd -c a1.d
How is the compiler able to know which file contains module a1?
Comment #3 by andrej.mitrovich — 2013-01-08T15:18:10Z
(In reply to comment #2)
> Then per module compilation can't work.
> dmd -c a1.d
Works fine here.
Comment #4 by code — 2013-01-08T15:54:25Z
>but you have to use the name in the
module declaration when importing
---
cat > a0.d << CODE
module foo;
CODE
cat > a1.d << CODE
import foo;
CODE
dmd -c a1.d
---
a1.d(1): Error: module foo is in file 'foo.d' which cannot be read
---
How is the compiler to know where to find the module foo?
Comment #5 by andrej.mitrovich — 2013-01-08T16:45:42Z
(In reply to comment #4)
> a1.d(1): Error: module foo is in file 'foo.d' which cannot be read
Right my bad, I used the wrong import. You can however use -c with multiple files as a workaround.
Walter will have to comment on this.
Comment #6 by andrej.mitrovich — 2013-01-09T07:07:42Z