Hey,

I'm trying to use a struct for RAII (like C++'s unique_ptr), so i @disabled this(this). However, it's still getting copied somehow:

struct A {
        int some_resource = 0;
        ~this() { if (some_resource) writeln("Freeing resource."); }
        @disable this(this); // Prevent copying
}

struct B {
        A a;
        alias a this;
}

void main() {
        B b;
        b.some_resource = 100;
        A a = move(b);
}

The above code prints 'Freeing resource.' twice!

See it in action on http://dpaste.dzfl.pl/6461df03

I guess the first one is from the temporary B that move(b) gives. However, that temporary should be moved into a and then left in B.init state, but that doesn't happen.

Is this a bug?

Reply via email to