On Sun, 11 Sep 2011 13:57:12 -0400, Walter Bright
<[email protected]> wrote:
On 9/11/2011 9:08 AM, Max Samukha wrote:
This test case
struct S
{
@disable this();
this(int x)
{
}
}
class C
{
S s;
this()
{
s = S(42);
}
}
void main()
{
auto c = new C;
}
yields Error: default construction is disabled for type C
Is it a bug?
No, it's a feature!
While I agree a nested "@disable this" struct inside a struct should
disable default construction of the outer struct, a class *requires*
initialization, and a default constructor is called explicitly (and can be
defined!) We are talking two different worlds here.
I think the above should be accepted. I'm not sure how feasible it is,
since it requires code path analysis.
-Steve