Bug 10895 – incorrect std.array.join behavior with array of string-like class using alias this
Status
RESOLVED
Resolution
FIXED
Severity
critical
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-25T23:34:00Z
Last change time
2015-10-04T18:20:44Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
thelastmammoth
Comments
Comment #0 by thelastmammoth — 2013-08-25T23:34:43Z
(posted under 'alias this bug?' in D newsgroup but didn't get any answer)
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!
}