www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - bug? array concatenation/append on struct

reply icee <iceelyne gmail.com> writes:
struct SPoint{
double x,y;
SPoint create(double x,double y){
SPoint p;
p.x=x;
p.y=y;
return p;
}
}
..
SPoint[] sps;
sps~=SPoint.create(2,4);//OK.

sps=sps~SPoint.create(2,4);//Internal error: ..\ztc\type.c 308, dmd v0.161

int[] a;
a~=2;//OK.
a=a~2;//OK.
Jun 26 2006
parent Dave <Dave_member pathlink.com> writes:
icee wrote:
 struct SPoint{
 double x,y;
 SPoint create(double x,double y){
 SPoint p;
 p.x=x;
 p.y=y;
 return p;
 }
 }
 ..
 SPoint[] sps;
 sps~=SPoint.create(2,4);//OK.
 
 sps=sps~SPoint.create(2,4);//Internal error: ..\ztc\type.c 308, dmd v0.161
 
 int[] a;
 a~=2;//OK.
 a=a~2;//OK.
 
I'll post the bug. Just to help narrow the problem down, this works: import std.stdio; struct SPoint { double x,y; static SPoint create(double x,double y) { SPoint p; p.x = x; p.y = y; return p; } } void main() { SPoint[] sps; sps ~= SPoint.create(1,2); //sps = sps ~ SPoint.create(2,4); //Internal error: ..\ztc\type.c 308 SPoint sp = SPoint.create(2,4); //This works sps = sps ~ sp; int[] a; a ~= 2; a = a ~ 2; foreach(p; sps) writefln(p.x,",",p.y); }
Jun 26 2006