Summary: Broken final switch on ints
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P2
         Component: DMD

--- Comment #0 from 2011-03-07 04:27:15 PST ---
The purpose of "final switch" is to increase code safety compared to normal
switches on enums. This D2 program compiles and runs with no errors (dmd

void main() {
    int x = 100;
    final switch (x % 3) {
        case 0: break;
        case 1: break;

Two possible ways for the D compiler to manage this code:
- Disallow it, not allowing final switches on int values;
- Manage it correctly and require the case "case 2:" too.
- (A third possibility: ignore the limited range of the switching value and
requiring coverage of the whole integer range, but this is not a good

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to