digitalmars.D.bugs - [Issue 22385] New: CTFE fails to iterate over associative array
- d-bugmail puremagic.com (32/32) Oct 13 2021 https://issues.dlang.org/show_bug.cgi?id=22385
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: nobody puremagic.com Reporter: timon.gehr gmx.ch 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]` --
Oct 13 2021