struct A
{
    int a;
    @disable ~this() {}
}

void main()
{
    A a = A(2);
}

Currently, this code yields:

Error: destructor `A.~this` cannot be used because it is annotated with @disable

I was expecting that disabling the destructor would make it as if the struct does not have a destructor, instead it makes the program not compile. I find this behavior odd: why not make it illegal to disable the destructor if disabling it will surely result in errors wherever the struct is used. The only situation where the code will compile is A is never used directly. To make matters even more confusing, this code compiles:

class A
{
    int a;
    @disable ~this() {}
}

void main()
{
    A a = new A();
}


So, is this a bug or am I missing something?

Yoroshiku onegaishimasu,
RazvanN

Reply via email to