January 15, 2024
https://issues.dlang.org/show_bug.cgi?id=24341

          Issue ID: 24341
           Summary: Switch over enum are poorly verified
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: b2.temp@gmx.com

Test case:

```
enum E : ubyte
{
    e0,
    e1
}

void oops(E e)
{
    switch (e)
    {
        case 300: break; // accepted but can be statically verified to be wrong
        default:
    }
}

void main()
{
}
```

there are two things here

1. even without E body, we know that 300 is out of range
2. with the body we can check that 300 is not 0 either 1.

But for now the compiler is just happy with that code.

Likely a problem of premature integral promotion.

This can cause problems when the definition of E is updated.

--