www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3061] New: Circular Import dependencies

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: tim.matthews7 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: -------
Jun 10 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3061


Rainer Schuetze <r.sagitario gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |r.sagitario gmx.de


--- Comment #1 from Rainer Schuetze <r.sagitario gmx.de> 2009-09-18 01:59:33
PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3061


Tim M <tim.matthews7 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Tim M <tim.matthews7 gmail.com> 2009-09-18 02:41:56 PDT ---
It was created for 2.030. Works for 2.032. Closing as fixed.

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