www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16644] New: final switch on int should error unless VRP

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 puremagic.com
          Reporter: code 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.

--
Oct 28 2016