https://issues.dlang.org/show_bug.cgi?id=22385
Issue ID: 22385
Summary: CTFE fails to iterate over associative array
previously indexed with implicit conversion to enum
base type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE, rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
DMD 2.098.0:
---
enum E:char[4]{ str="abcd" }
enum x={
int[char[4]] aa;
aa[E.str]=0;
foreach(key,val;aa){} // error
return 0;
}();
---
Error: cannot cast `"abcd"` to `char[4]` at compile time
called from here: `(*function () => 0)()`
---
The code should compile.
Workaround: `aa[cast(char[4])E.str]`
--