[Issue 16644] New: final switch on int should error unless VRP matches all cases

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Oct 28 16:16:25 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16644

          Issue ID: 16644
           Summary: final switch on int should error unless VRP matches
                    all cases
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: code at dawg.eu

To determine whether all cases are handled, we could use value range
propagation.

OK

final switch (i % 2)
{
case 0:
case 1:
}

ERROR
final switch (i % 3)
{
case 0:
case 1:
}

In cases where we don't know the range, it should be an error.

--


More information about the Digitalmars-d-bugs mailing list