<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">is this a bug?</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">the call to join invalidates the "name" field of A:</div>
<div style="font-family:arial,sans-serif;font-size:12.727272033691406px"><br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> </div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
----</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">import std.array;</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">import std.stdio;</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
class A{</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> string name;</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> this(string name){<a href="http://this.name/" target="_blank">this.name</a>=name;}</div>
<div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> alias name this;</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> ~this(){</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
writeln("deleting");</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> }</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">}</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
<br></div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">void main(){</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> auto a=[new A(`foo`)];</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px">
assert(a[0].length);</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> writeln("1");</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> auto temp=a.join(" ");</div>
<div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> writeln("2");</div><div style="font-family:arial,sans-serif;font-size:12.727272033691406px"> assert(!a[0].length); //a[0] is now empty!</div>
<div style="font-family:arial,sans-serif;font-size:12.727272033691406px">}</div></div>