Summary: illegal to refer to 'this' implicitly or explicitly
           Product: D
           Version: 2.032
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, spec
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Sobirari Muhomori <> 2009-10-13 
07:44:56 PDT ---
Spec reads: 3. It is illegal to refer to this implicitly or explicitly prior to
making a constructor call. Although it's allowed.

class A
    int a;
    this(){ M(); this(1); }
    this(int b){ a=b; }
    void M(){ writeln("A.M"); }

class B:A
    int b;
    this(){ M(); super(); b=5; }
    override void M(){ writeln("B.M ",b); }

int main()
    auto b=new B();
    return 0;

output is
B.M 0
B.M 0
B.M 5

We see how virtual method is called prior to constructor calls and overridden
method from derived class is called from the constructor of the base class
(called on not yet constructed object).

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

Reply via email to