Bug 2878 – Forward reference error with circular import and nested classes

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2009-04-22T08:38:00Z
Last change time
2014-04-18T09:12:02Z
Keywords
rejects-valid
Assigned to
nobody
Creator
benoit
Blocks
340

Comments

Comment #0 by benoit — 2009-04-22T08:38:29Z
compile with "dmd M N" === M.d === Start module M; import N; abstract class Format{ static class Field {} abstract void doit( FieldPosition p ); } void main(){} === M.d === End === N.d === Start module N; import M; class FieldPosition { static class F2 : M.Format.Field { } this( M.Format.Field f){ } } === N.d === End Messages: M.d(3): Error: class M.Format is forward referenced when looking for 'Field' M.d(3): Error: class M.Format is forward referenced when looking for 'Field' M.d(3): Error: class M.Format is forward referenced when looking for 'Field' N.d(6): Error: no property 'Field' for type 'M.Format' N.d(6): Error: M.Format.Field is used as a type N.d(6): Error: class N.FieldPosition.F2 base type must be class or interface, not void M.d(3): Error: class M.Format is forward referenced when looking for 'Field' M.d(3): Error: class M.Format is forward referenced when looking for 'Field' M.d(3): Error: class M.Format is forward referenced when looking for 'Field' N.d(8): Error: no property 'Field' for type 'M.Format' N.d(8): Error: M.Format.Field is used as a type N.d(8): Error: cannot have parameter of type void
Comment #1 by smjg — 2009-04-22T20:17:59Z
This could be related to bug 102. Except that this one compiles without error if N is given on the command line first.
Comment #2 by r.sagitario — 2009-09-18T01:54:02Z
I could not reproduce this bug with DMD 1.047 and DMD 2.032.
Comment #3 by clugdbug — 2009-09-18T15:22:42Z
(In reply to comment #2) > I could not reproduce this bug with DMD 1.047 and DMD 2.032. I do not get any errors from file M, only from file N. Even when using DMD1.041, or 1.010 -- so I can't reproduce the original bug. It still fails to compile, however -- all the file N errors are still present in 1.047 and 2.032.
Comment #4 by r.sagitario — 2009-09-19T01:01:46Z
Hmmm, strange. I double-checked: no errors for 1.047 and 2.032, but the same errors as in the original report for 1.046 and 2.031. I've just copied the code from the report. Have you made any modification? The source changes for 2.031 and 2.032 also deal with this problem, see "mustsemantic" in class.c (though I could not see in the debugger, that the changes in 2.032 kick in...)
Comment #5 by clugdbug — 2009-09-19T11:38:05Z
You are quite right. I was using different filenames, and stuffed up the translation -- I still had M.Format.Field. Yes, this is fixed in 1.047.