one path skips constructor

Johan Engelen j at j.nl
Mon Jan 14 14:27:22 UTC 2019


On Sunday, 13 January 2019 at 16:29:27 UTC, Kagamin wrote:
> ---
> struct A
> {
>     int a;
>     this(int)
>     {
>         if(__ctfe)this(0,0); //Error: one path skips constructor
>         else a=0;
>     }
>     this(int,int){ a=1; }
> }
> ---
> Is this supposed to not compile?

Yes.

See spec 14.14.8.1:
https://dlang.org/spec/struct.html#struct-constructor

-Johan



More information about the Digitalmars-d-learn mailing list