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
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
Code:
===
import std.conv;
import std.regex;
struct A
{
int field1;
int field2;
this(int field1, int field2)
{
if(field1 > field2)
throw new Exception("This is illegal!");
}