Thread overview |
---|
March 08, 2008 [Issue 1899] New: AA of fixed-length arrays fails to initialize | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1899 Summary: AA of fixed-length arrays fails to initialize Product: D Version: 2.012 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: ddparnell@bigpond.com The following code fails with an ArrayBoundsError on the assignment. void main() { int[3][string] AA; AA["abc"] = [5,4,3]; } But this code does not fail ... void main() { struct S { int[3] v; } S[string] AA; AA["abc"] = S([5,4,3]); } -- |
July 13, 2010 [Issue 1899] AA of fixed-length arrays fails to initialize | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1899 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsimcha@yahoo.com --- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-07-13 08:06:19 PDT --- *** Issue 4343 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 19, 2011 [Issue 1899] AA of fixed-length arrays fails to initialize | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1899 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch CC| |clugdbug@yahoo.com.au --- Comment #2 from Don <clugdbug@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: ------- |
January 23, 2011 [Issue 1899] AA of fixed-length arrays fails to initialize | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1899 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |chatelet.guillaume@gmail.co | |m --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-01-23 12:52:24 PST --- *** Issue 5292 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
February 06, 2011 [Issue 1899] AA of fixed-length arrays fails to initialize | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1899 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-02-06 13:49:34 PST --- Fixed https://github.com/D-Programming-Language/dmd/commit/fce5be52f1a7b7e4f910d8bc4ee2b632f6fc9843 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation