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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6283 - [CTFE][Regression 2.054] Failed to assign to AA using a constness-changed array as key
Summary: [CTFE][Regression 2.054] Failed to assign to AA using a constness-changed arr...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2011年07月10日 12:57 UTC by kennytm
Modified: 2011年07月26日 15:19 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011年07月10日 12:57:54 UTC
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 kennytm 2011年07月10日 13:07:57 UTC
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 3 kennytm 2011年07月22日 01:23:57 UTC
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 kennytm 2011年07月22日 01:40:27 UTC
(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).


AltStyle によって変換されたページ (->オリジナル) /