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

           Summary: Circular imports and static constructors in templates
           Product: D
           Version: 1.039
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: samu...@voliacable.com


Static constructor in a template belongs to the module declaring the template,
not the module where the template is instantiated (for template instances that
are not mixed-in). The following works and that's cool:

----
module a;
template Foo(int i)
{
  static this()
  {
  }
}

----
module b;
import a;
alias Foo!(1) foo;

----
module c;
import a;
alias Foo!(1) foo;

----

But if we have two separate instances, the example fails with  
'Error: circular initialization dependency with module b'

----
module b;
import a;
alias Foo!(1) foo;

----
module c;
import a;
alias Foo!(2) foo;

----

If there is another way to emulate static constructors in circularly imported
modules (not by manually calling an initialization function), please share.


-- 

Reply via email to