Escaped scoped

bearophile bearophileHUGS at lycos.com
Mon Jan 4 02:52:19 PST 2010


If I compile the following code with DMD with and without the scope annotation I can see that both versions compile and the version with scope deletes the object. Is the compiler acting correctly here? I'd like the compiler to refuse to compile this code when the scope attribute is present (this is a reduced example from a bug I've just removed from a program of mine):

class Foo {}
class Bar {
    Foo x;
    void spam() {
        scope Foo temp = new Foo();
        this.x = temp;
    }
}
void main() {}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list