August 24, 2013 alias this bug? | ||||
|---|---|---|---|---|
| ||||
Attachments:
| is this a bug?
the call to join invalidates the "name" field of A:
----
import std.array;
import std.stdio;
class A{
string name;
this(string name){this.name=name;}
alias name this;
~this(){
writeln("deleting");
}
}
void main(){
auto a=[new A(`foo`)];
assert(a[0].length);
writeln("1");
auto temp=a.join(" ");
writeln("2");
assert(!a[0].length); //a[0] is now empty!
}
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply