Bug 4517 – final switch over with base type allows missing values
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-27T00:37:00Z
Last change time
2012-07-18T02:49:35Z
Keywords
accepts-invalid, pull
Assigned to
yebblies
Creator
braddr
Comments
Comment #0 by braddr — 2010-07-27T00:37:46Z
module finalswitch;
enum foo : ushort
{
A = 1,
B = 3
}
void bar(foo f)
{
final switch(f)
{
case foo.A:
break;
}
}
This compiles without error:
$ dmd -c finalswitch.d
$
Dropping the ': ushort' part and it correctly identifies the missing case:
$ dmd -c finalswitch.d
finalswitch.d(11): Error: enum member B not represented in final switch
Comment #1 by verylonglogin.reg — 2012-01-24T02:52:28Z
*** Issue 7320 has been marked as a duplicate of this issue. ***
Comment #2 by verylonglogin.reg — 2012-01-24T03:57:22Z
This bug takes place if the enum base type is [u]byte, [u]short, [w|d]char, or an enum with one of these types as a base type.