Comment #0 by jason.james.house — 2010-06-07T19:16:47Z
$ cat test.d
struct x{
@disable this(); // line 2
this(bool b){ _b = b; }
bool _b;
}
int main(){
x; // line 7, the real source of the error
return cast(int) x._b;
}
$ dmd test.d
test.d(2): Error: constructor test.x.this default constructor not allowed for structs
Comment #1 by braddr — 2010-06-07T21:26:49Z
Maybe there's a missing error at line 7, but the error from line 2 means what it says.. default (aka zero arg) ctors aren't allowed for structs. Now, while I don't agree with that part of the d2 spec, that's a different issue.
ie, nothing to disable.
Comment #2 by jason.james.house — 2010-06-08T03:31:12Z
My goal with doing this was to catch uses of the default constructor because in the original use case, it was always a bug.
Comment #3 by k.hara.pg — 2012-05-30T17:41:55Z
In 2.060head, original code prints correct line number.
test.d(7): Error: type has no effect in expression (x)