D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2878 - Forward reference error with circular import and nested classes
Summary: Forward reference error with circular import and nested classes
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 major
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2009-04-22 08:38 UTC by Frank Benoit
Modified: 2014-04-18 09:12 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Frank Benoit 2009-04-22 08:38:29 UTC
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 Stewart Gordon 2009-04-22 20:17:59 UTC
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 Rainer Schuetze 2009-09-18 01:54:02 UTC
I could not reproduce this bug with DMD 1.047 and DMD 2.032.
Comment 3 Don 2009-09-18 15:22:42 UTC
(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 Rainer Schuetze 2009-09-19 01:01:46 UTC
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 Don 2009-09-19 11:38:05 UTC
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.