D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 946 - (D1 only) Circular reference undetected in some cases
Summary: (D1 only) Circular reference undetected in some cases
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2007-02-10 10:54 UTC by Vladimir Panteleev
Modified: 2013-11-15 20:35 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2007-02-10 10:54:05 UTC
====== A.d ======

module A;

import std.stdio;
import B;

int Avar;

static this()
{
	Avar = 5;
	writefln(Bvar);
}

void main()
{
}

====== B.d ======

module B;

import std.stdio;
import C;

int Bvar;

static this()
{
	Bvar = 5;
	writefln(Avar);
}

====== C.d ======

module C;

public import A;

=================

The program compiles, and outputs:

0
5

(A's constructor gets called before B's).

Related code is in _moduleCtor2 from moduleinit.d - if a module has no static constructors/destructors, any circular references in its imported modules are ignored (the skip parameter).
Comment 2 yebblies 2012-01-31 20:04:54 UTC
Has been fixed in D2 only.
Comment 3 Andrei Alexandrescu 2013-11-15 20:35:21 UTC
Closing because D1 is no longer supported.