Bug 6285 – switch-case statement fails for enums of strings
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Mac OS X
Creation time
2011-07-10T13:59:00Z
Last change time
2011-07-10T14:18:36Z
Assigned to
nobody
Creator
blazej.podsiadlo
Comments
Comment #0 by blazej.podsiadlo — 2011-07-10T13:59:13Z
Hi,
Switch-case statement fails for enums of strings because it is not of integral type.
For the following code:
enum strEnum : string {strA = "strA", strB = "strB"};
strEnum se = strEnum.strA;
switch (strEnum) {
case strEnum.strA: break;
};
I get the error message:
Error: 'strEnum' is not of integral type, it is a strEnum
In the same moment, I can workaround that by:
string realStr = strEnum.strA;
switch (realStr) {
case strEnum.strA: break;
};
Unfortunately it doesn't help in my case where I want use final switch:
final switch (strEnum) {
case strEnum.strA: break;
case strEnum.strB: break;
};
Best Regards
Blazej
Comment #1 by kennytm — 2011-07-10T14:18:36Z
*** This issue has been marked as a duplicate of issue 2950 ***