[Issue 21389] New: case statement in bad switch wrongly reported as duplicated

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 13 15:22:06 UTC 2020


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

          Issue ID: 21389
           Summary: case statement in bad switch wrongly reported as
                    duplicated
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

For the following bad code

---
enum E : ubyte { e0, e1, e3, e4 }

void main()
{
    switch (node.e)
    {
        case E.e0: return;
        case E.e1: return;
        default: return;
    }
} 
---

DMD reports:

> /tmp/temp_7FAD2C00A670.d:10:13: Error: undefined identifier `node`
> /tmp/temp_7FAD2C00A670.d:13:9: Error: duplicate `case e1` in `switch` statement

The first error message is correct.
The second error message is a bad diagnostic.

--


More information about the Digitalmars-d-bugs mailing list