Comment #0 by tim.matthews7 — 2009-06-10T06:28:12Z
Created attachment 398
reproduceable error
In order for the dnet (D dot net compiler based on dmd front end) to work, import files for the dot net declarations must be generated. According to this page http://digitalmars.com/d/2.0/overview.html forward declarations are a feature to drop from C/C++ but this needs to be implemented to the full extent for dnet compiler to parse anything.
Sometimes types don't depend on each other at the same but other types within their namespace depend on them and the import statements cause the error. I have reduced this down to a simple example which I have attached as test-forward.rar. In this example compile test.d using 2.030 dmd.
C:\d\phobos\dmd\projects\test-forward>dmd test.d
two.d(5): Error: template instance forward reference to template declaration A(T)
two.d(5): Error: A!(B) is used as a type
two.d(5): Error: class two.B base type must be class or interface, not void
test.d imports one.d
one.d imports two.d
two.d imports and actually depends on one.d
when dmd reaches the "import two;" from the file "one.d" it decides that "two.d" is required to parse the remaing contents but it is infact the other way round.
The dependency parsing needs to be rethinked from scratch. Not sure the exacts of the algorithm but maybe create stub declarations that gradually get more details added to them during the parsing and only check for errors once everything is in place. I think this is how dot net would compile everything as the whole dot net platform is very tightly interlinked.
Comment #1 by r.sagitario — 2009-09-18T01:59:33Z
I could not reproduce this bug with DMD 1.047 and DMD 2.032. A less-reduced test case might still fail, as this problem seems to be related to bug 3301 and other circular imports issues. The patch there might help, though.
Comment #2 by tim.matthews7 — 2009-09-18T02:41:56Z
It was created for 2.030. Works for 2.032. Closing as fixed.