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.
Comment #3 by yebblies — 2012-01-30T19:17:31Z
Comment #4 by github-bugzilla — 2012-07-16T23:34:17Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ef6d2e16bebb7c4a0a17eb2c34af2657c9996b38 Issue 4517 - final switch over with base type allows missing values Integral promotions kills the type of the condition and the case expressions, so keep track of the original enum type and allow cases to match if they evaluate to the same integer expression. Fixes issue4517 https://github.com/D-Programming-Language/dmd/commit/00778d310b6980ac7068398f4dac22aa4860b8d4 Merge pull request #662 from yebblies/issue4517 Issue 4517 - final switch over with base type allows missing values