[Issue 5713] New: Broken final switch on ints

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 7 04:30:14 PST 2011


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: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at 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: -------


More information about the Digitalmars-d-bugs mailing list