January 13, 2019 one path skips constructor | ||||
---|---|---|---|---|
| ||||
--- 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? |
January 14, 2019 Re: one path skips constructor | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | 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 |
Copyright © 1999-2021 by the D Language Foundation