www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15485] New: switch with no case compiles

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

          Issue ID: 15485
           Summary: switch with no case compiles
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: trivial
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: alex sunopti.com

The below code compiles, but fails at run time with "No appropriate switch
clause found".
This could be made a compiler error.


void main()
{
    int x = 10;
    switch (x)
    {
        if (x == 10)
        {
            return;
        }
    }
}

--
Dec 30 2015