[Issue 3061] New: Circular Import dependencies

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 10 06:28:12 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3061

           Summary: Circular Import dependencies
           Product: D
           Version: 2.030
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: tim.matthews7 at gmail.com


Created an attachment (id=398)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list