Re: one path skips constructor

2019-01-14 Thread Johan Engelen via Digitalmars-d-learn
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

one path skips constructor

2019-01-13 Thread Kagamin via Digitalmars-d-learn
--- 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?

Re: One path skips constructor - is this a bug?

2017-09-07 Thread Johan Engelen via Digitalmars-d-learn
On Thursday, 7 September 2017 at 16:08:53 UTC, Piotr Mitana wrote: main.d(17): Error: one path skips constructor main.d(15): Error: return without calling constructor http://www.digitalmars.com/d/archives/digitalmars/D/learn/Throwing_exception_in_constructor_28995.html

Re: One path skips constructor - is this a bug?

2017-09-07 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 7 September 2017 at 16:08:53 UTC, Piotr Mitana wrote: Code: === import std.conv; import std.regex; struct A This throws a compilation error: main.d(17): Error: one path skips constructor main.d(15): Error: return without calling constructor Why

One path skips constructor - is this a bug?

2017-09-07 Thread Piotr Mitana via Digitalmars-d-learn
main() { A(2004, 43); A("2004-43"); } === This throws a compilation error: main.d(17): Error: one path skips constructor main.d(15): Error: return without calling constructor Why do I need the constructor call, if I throw the exception anyway? Is this a bug?