Bug 6283 – [CTFE][Regression 2.054] Failed to assign to AA using a constness-changed array as key

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Mac OS X
Creation time
2011-07-10T12:57:00Z
Last change time
2011-07-26T15:19:58Z
Keywords
rejects-valid
Assigned to
nobody
Creator
kennytm

Comments

Comment #0 by kennytm — 2011-07-10T12:57:54Z
Test case: ----------------------------------- static assert( { immutable qq = "qq"; string q = qq; // <-- from immutable(char[]) to immutable(char)[] int[string] pieces = ["a":1]; pieces[q] = 0; // <-- can't interpret return true; }() ); ----------------------------------- x.d(9): Error: cannot evaluate delegate pure nothrow bool() { immutable immutable(char[]) qq = "qq"; string q = qq; int[string] pieces = ["a":1]; pieces[q] = 0; return true; } () at compile time x.d(1): Error: static assert (delegate pure nothrow bool() { immutable immutable(char[]) qq = "qq"; string q = qq; int[string] pieces = ["a":1]; pieces[q] = 0; return true; } ()) is not evaluatable at compile time -----------------------------------
Comment #1 by kennytm — 2011-07-10T13:07:57Z
The regression was introduced in commit 08352 in fixing the type-painting bug revealed by bug 4063. https://github.com/D-Programming-Language/dmd/commit/08352
Comment #2 by bugzilla — 2011-07-21T20:34:18Z
Comment #3 by kennytm — 2011-07-22T01:23:57Z
Not yet fixed in these 2 slight variants: Test case 2: ----------------------------------- static assert({ immutable p = "pp"; int[string] pieces = [p: 0]; pieces["qq"] = 1; return true; }()); ----------------------------------- x.d(6): Error: cannot evaluate delegate pure nothrow bool() .... ----------------------------------- Test case 3: ----------------------------------- static assert({ immutable renames = [0: "pp"]; int[string] pieces; pieces[true ? renames[0] : "qq"] = 1; pieces["anything"] = 1; return true; }()); ----------------------------------- x.d(7): Error: cannot evaluate delegate pure nothrow bool() .... -----------------------------------
Comment #4 by kennytm — 2011-07-22T01:40:27Z
(In reply to comment #3) > Not yet fixed in these 2 slight variants: > [snip] ... and the cause of these 2 variants are the same: Equals() in constfold.c cannot handle (e1->op == TOKslice && e2->op == TOKstring).
Comment #5 by bugzilla — 2011-07-26T15:19:58Z