Bug 209 – "Diamond" import name conflicts when using Fully Qualified names

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-06-19T09:38:00Z
Last change time
2014-02-15T13:19:04Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
bruno.do.medeiros+deebugz

Comments

Comment #0 by bruno.do.medeiros+deebugz — 2006-06-19T09:38:18Z
In a "diamond-shaped" structure of imports, name conflicts occur on the bottom module when accessing top module entities with a fully qualified name (because the top module name itself conflicts). Example: ---- foo.d ---- module foo; int fooEnt; // could a be a class, func, any other entity. ---- barA.d ---- module barA; import foo; ---- barB.d ---- module barA; import foo; ---- test.d ---- import barA; import barB; void main() { fooEnt++; // Compiles ok. (Correct) foo.fooEnt++; // Compile error, name conflicts (INCORRECT) : // barA.d(3): import barA.foo conflicts with barB.foo at barB.d(3) alias foo xxx; // Compile error too, // accessing the top module is enough to trigger it } This bug does not happen if the "root name" (first name) of the top and middle modules is the same, such as this: ---- mod.foo.d ---- module mod.foo; int fooEnt; // could a be a class, func, any other entity. ---- mod.barA.d ---- module mod.barA; import mod.foo; ---- mod.barB.d ---- module mod.barA; import mod.foo; ---- test.d ---- import mod.barA; import mod.barB; void main() { fooEnt++; // Compiles ok. (Correct) mod.foo.fooEnt++; // Compiles ok. (Correct) }
Comment #1 by smjg — 2006-06-19T10:24:47Z
(In reply to comment #0) > ---- barB.d ---- > module barA; > > import foo; Shouldn't this be module barB; ?
Comment #2 by bruno.do.medeiros+deebugz — 2006-06-19T10:28:40Z
(In reply to comment #1) > (In reply to comment #0) > > ---- barB.d ---- > > module barA; > > > > import foo; > Shouldn't this be > module barB; > ? Agh, yes indeed. :/ Same for: ---- mod.barB.d ---- module mod.barA; // shoulde be barB
Comment #3 by bruno.do.medeiros+deebugz — 2006-07-12T17:18:00Z
Hum, seems this was partially fixed in DMD.161 : The example above works since DMD.161, but there is one other that doesn't currently(.162), this one is not "diamond" shaped anymore since the top is folded into two. Let's see the code: ---- test.d ---- module test; import tierOneA; import tierOneB; alias pack.fooA XXX; // the above gets the error: // import tierOneA.pack conflicts with tierOneB.pack at tierOneB.d(3) ---- tierOneA.d ---- module tierOneA; import pack.fooA; ---- tierOneB.d ---- module tierOneB; import pack.fooB; ---- pack.fooA ---- module pack.fooA; // this is the second tier A ---- pack.fooB ---- module pack.fooB; // this is the second tier B
Comment #4 by bruno.do.medeiros+deebugz — 2006-07-29T12:00:50Z
(In reply to comment #3) > ... Add "public" to the imports of tierOneA and tierOneB to update this example to DMD 0.163 . (Although the error still appears with private imports)
Comment #5 by bruno.do.medeiros+deebugz — 2006-08-16T19:47:24Z
New bug cloned, this one (mysteriously?) fixed on DMD.161 .
Comment #6 by braddr — 2007-04-03T12:24:18Z
For the audit log, and in case some sort of data inconsistency arises, I performed these sql commands to delete attachment and comment spam: mysql> delete from attachments where attach_id >= 107 and attach_id <= 136; Query OK, 30 rows affected (0.00 sec) mysql> delete from longdescs where bug_id=209 and who=223; Query OK, 30 rows affected (0.00 sec)