Bug 5590 – Regression(2.036) ICE(e2ir.c): when using .values on enum which is associative array
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-02-15T02:26:00Z
Last change time
2012-03-03T10:46:43Z
Keywords
ice, patch
Assigned to
nobody
Creator
issues.dlang
Comments
Comment #0 by issues.dlang — 2011-02-15T02:26:28Z
On dmd 2.051, this code
import std.path;
import std.range;
enum aa = [5 : "hello"];
void main(string[] args)
{
auto a = aa.values.front;
}
fails to compile, giving this error: Internal error: e2ir.c 4617
With the current beta, it gives: Internal error: e2ir.c 4835
This may or may not be a duplicate of bug# 4460. I don't know enough about the compiler details to know for sure, but it does seem similar. It's definitely not quite the same circumstances though, so I'm creating a new bug just in case it is something separate.
Comment #1 by kennytm — 2011-03-14T16:33:10Z
*** Issue 5734 has been marked as a duplicate of this issue. ***
Comment #2 by kennytm — 2011-04-13T03:45:15Z
The same happens for all other AA methods (.get, .length, etc).
Comment #3 by clugdbug — 2011-04-28T08:41:30Z
*** This issue has been marked as a duplicate of issue 4460 ***
Although this is a regression, it isn't recent. It last worked in 2.035
Minimal test case is:
enum aa = [5 : "hello"];
void bug5520()
{
auto a = aa.values;
}
Comment #9 by yebblies — 2012-02-09T08:20:09Z
For anyone interested in why this bug exists:
When the 'aa' of 'aa.values' reaches e2ir, it is an 'ArrayLiteralExp' but is typed as the 'AssociativeArray' struct, because the type is changed in order to do member lookup. Changing the type back to an AA doesn't work, I assume because _d_assocarrayliteralTX returns a reference to an associative array and the compiler gets very confused about where it's actually stored, which seems to result in the wrong values in registers when .values is called. Or, it would if it didn't have the wrong type when it hit ::toElem.
This only applies to the AA methods that only exist in the AssociativeArray struct in object.di
Comment #10 by github-bugzilla — 2012-03-03T00:33:01Z