Can't seem to call super constructor if it's a template

Meta jared771 at gmail.com
Mon Aug 10 19:03:40 UTC 2020


On Monday, 10 August 2020 at 18:37:06 UTC, Andrei Alexandrescu 
wrote:
> class A {
>     this(T)() {}
> }
>
> class B : A {
>     this() { super!int(); }
> }
>
> Error: found ! when expecting ; following statement
>
> That should work, shouldn't it?

Unfortunately this doesn't work either:

class A {
     this(T)() {}
}

class B : A {
     //Error: constructor onlineapp.B.this no match for implicit 
super() call in constructor
     this()
     {
         super.__ctor!int();
     }
}


Because super.__ctor apparently doesn't count as a call to the 
superclass's constructor for the flow analysis.


More information about the Digitalmars-d mailing list