http://d.puremagic.com/issues/show_bug.cgi?id=5713

           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
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 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
2.052):


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
solution).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to