Why, in the following piece of code, destructor for 'x' is never called? class A{ char [] s; this(char [] o_s){ s = o_s; } ~this(){ writefln(s); }; }
void main(){ A y; { scope A x = new A("x".dup); y = new A("y".dup); x = y; // } } output: y // where is x Destructors for scope objects are executed, because: void main(){ A y; { scope A x = new A("x".dup); y = new A("y".dup); // x = y; } } output: x y and for assignment too: void main(){ A y; { A x = new A("x".dup); y = new A("y".dup); x = y; } } output: y x