Bug 8748 – the module name must not be unique in the pack and its subpacks

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2012-10-03T14:21:00Z
Last change time
2013-01-11T18:00:23Z
Assigned to
nobody
Creator
blazej.podsiadlo

Attachments

IDFilenameSummaryContent-TypeSize
1145use_case.tar.gzthe full use caseapplication/x-gzip854

Comments

Comment #0 by blazej.podsiadlo — 2012-10-03T14:21:07Z
Created attachment 1145 the full use case Hi, I've got following problem: It's possible to build following library: the_lib/ ├── sub_pack │   └── the_mod.d └── the_mod.d by following commands: mkdir -p build/the_lib mkdir -p build/the_lib/sub_pack cd build dmd -c -I../ ../the_lib/sub_pack/the_mod.d -ofthe_lib/sub_pack/the_mod.o dmd -c -I../ ../the_lib/the_mod.d -ofthe_lib/the_mod.o dmd -lib -I../ the_lib/the_mod.o the_lib/sub_pack/the_mod.o -ofthe_lib/libTheLib However it's not possible to use it later on: import the_lib.the_mod; import the_lib.sub_pack.the_mod; import std.stdio; void main() { writeln("the_app::main()"); the_lib.the_mod.the_fun(); the_lib.sub_pack.the_mod.the_fun(); } built by: dmd -c -I../ ../the_app/main.d -ofthe_app/main.o dmd the_app/main.o the_lib/libTheLib.a -ofthe_app/main produces: ../the_app/main.d(2): Error: module the_mod from file ../the_lib/sub_pack/the_mod.d conflicts with another module the_mod from file ../the_lib/the_mod.d ================= in the same time when I try following code: [developer@prv-dev-srv dmd-bug]$ cat the_app/clue.d import the_lib.sub_pack.the_mod; import std.stdio; void main() { writeln("the_app::main()"); the_lib.sub_pack.the_mod.the_fun(); } compiles, but doesn't work as intended: execution of: the_lib.sub_pack.the_mod.the_fun(); executes code of the_lib.the_mod.the_fun(); I think that case, is much more serious than the first one because leads to unexpected behaviours and does not produce any warnings/errors. =================== I've attached the preprepared "project" demonstrating that issue (dmd-bug) and as well some "workaround" (dmd-fine) where all modules have unique names. =================== I use DMD 2.60 @ CentOS 6.3 32bit. Best Regards, Blazej Podsiadlo
Comment #1 by andrej.mitrovich — 2013-01-11T18:00:23Z
Import declarations are not C include statements, if you import 'foo.bar', then you must have a module with a declaration 'module foo.bar;', regardless of where it's located.