3286 – Default parameter prevents to resolve inter-module circular dependency

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3286 - Default parameter prevents to resolve inter-module circular dependency
Summary: Default parameter prevents to resolve inter-module circular dependency
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2009年09月03日 07:57 UTC by HOSOKAWA Kenchi
Modified: 2015年06月09日 01:26 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description HOSOKAWA Kenchi 2009年09月03日 07:57:52 UTC
module a;
import b;
import c;
class A {
	static __gshared A a;
	void f(B b) {}
	void g(C c) {} // <- Error: identifier 'C' is not defined
}
////////////
module b;
import a;
class B { void f(A x = A.a) {} }
////////////
module c;
import a;
class C { void f(A x = A.a) {} }
There is no problem if class A, B and C are in the same module.
So this dependency is valid and the error is specific for inter-module circular dependency.
If default parameter "= A.a" for B.f is removed, it goes well.
There is no problem if A.a appeared in the body of B.f.
It seems that the compiler tries to recognize the semantics of default parameter A.a when it is reading declaration of B.f.
Default parameters are usually hint for the expressions which call the functions with default parameters, this behavior is inexplicable.
This error is a regression between 2.031 and 2.032.
Comment 1 HOSOKAWA Kenchi 2009年09月03日 08:22:24 UTC
Sorry, this error is NOT a regression between 2.031 and 2.032.
This error is occur with 2.031.
I found similar error which is a regression between 2.031 and 2.032, and I was confused.
Sorry.
Comment 2 Rainer Schuetze 2009年09月18日 00:49:24 UTC
The patch in issue 3301 also fixes this issue.
Comment 3 Walter Bright 2009年10月13日 13:47:07 UTC
Fixed dmd 1.049 and 2.034


AltStyle によって変換されたページ (->オリジナル) /