digitalmars.D.learn - one path skips constructor
- Kagamin (13/13) Jan 13 2019 ---
- Johan Engelen (5/18) Jan 14 2019 Yes.
--- 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?
Jan 13 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
Jan 14 2019