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 -----------------------------------
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
https://github.com/D-Programming-Language/dmd/commit/3309fcddfbc4e445a3e418c31a49d157c33161aa https://github.com/D-Programming-Language/dmd/commit/2ea02077de9498746f5abb0043dc6ae1e5accefc
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() .... -----------------------------------
(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).
https://github.com/D-Programming-Language/dmd/commit/0904c8aa200e4d080d500d96d5904c33ba17cc86 https://github.com/D-Programming-Language/dmd/commit/e48a8c67f02172c72e04f36759d2d6868d716368