enum TestEnum : string { f = "first", s = "second", t = "third" }
void main ()
{
TestEnum en = TestEnum.s;
switch (en)
{
case TestEnum.f:
break;
case TestEnum.s:
break;
case TestEnum.t:
break;
}
}
enumBug.d(10): Error: Integer constant expression expected instead of "first"
enumBug.d(12): Error: Integer constant expression expected instead of "second"
enumBug.d(14): Error: Integer constant expression expected instead of "third"
Comment #1 by tomeksowi — 2010-10-22T14:02:22Z
*** Issue 4670 has been marked as a duplicate of this issue. ***
Comment #2 by kennytm — 2011-07-10T14:18:36Z
*** Issue 6285 has been marked as a duplicate of this issue. ***
Comment #3 by andrej.mitrovich — 2012-10-26T16:20:10Z
Created attachment 1157
Partial patch
Partial patch against commit 6c01188d71433508bc4c0af6b821a97e8df2e986
The problem is this won't compile with -g option.
When `EnumDeclaration::toDebug` is called, it calls cv4_Denum, which expects the enum to have an integer base type. It tries to call `toInteger` method on the enum declaration.
`cv4_Denum` is a complicated function, I don't know how to implement a fix there.
Comment #4 by andrej.mitrovich — 2012-12-08T09:22:38Z