www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10895] New: alias this bug?

http://d.puremagic.com/issues/show_bug.cgi?id=10895

           Summary: alias this bug?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com



(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!
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2013