http://d.puremagic.com/issues/show_bug.cgi?id=1899
Don clugd...@yahoo.com.au changed:
What|Removed |Added
Keywords||patch
CC||clugd...@yahoo.com.au
--- Comment #2 from Don clugd...@yahoo.com.au 2011-01-19 13:12:10 PST ---
PATCH: AssignExp::semantic(). We mustn't convert it into a slice assignment,
because it may be a construction.
Also require an implicit conversion, so that we can allow assignment of array
literals. Quick test case:
void bug1899()
{
int[3][string] AA;
int[3] x = [5,4,3];
AA[abc] = x;
assert(AA[abc] == x);
AA[def] = [1,2,3];
assert(AA[def]==[1,2,3]);
}
---
Index: expression.c
===
--- expression.c(revision 882)
+++ expression.c(working copy)
@@ -9086,10 +9086,23 @@
}
if (t1-ty == Tsarray !refinit)
-{ // Convert e1 to e1[]
+{
+if (e1-op == TOKindex
+((IndexExp *)e1)-e1-type-toBasetype()-ty == Taarray)
+{
+// Assignment to an AA of fixed-length arrays.
+// Convert T[n][U] = T[] into T[n][U] = T[n]
+e2 = e2-implicitCastTo(sc, e1-type);
+if (e2-type == Type::terror)
+return e2;
+}
+else
+{
+// Convert e1 to e1[]
Expression *e = new SliceExp(e1-loc, e1, NULL, NULL);
e1 = e-semantic(sc);
t1 = e1-type-toBasetype();
+}
}
e2-rvalue();
@@ -9131,8 +9144,13 @@
else if (t1-ty == Tsarray)
{
/* Should have already converted e1 = e1[]
+ * unless it is an AA
*/
-assert(op == TOKconstruct);
+if (!(e1-op == TOKindex t2-ty == Tsarray
+((IndexExp *)e1)-e1-type-toBasetype()-ty == Taarray))
+{
+assert(op == TOKconstruct);
+}
//error(cannot assign to static array %s, e1-toChars());
}
else if (e1-op == TOKslice)
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---