Summary: Default parameter prevents solution of inter-module
                    circular dependency
           Product: D
           Version: 2.032
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD

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

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.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to