Summary: Disallow unreachable statements in switch clause
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2011-05-12 
15:23:13 PDT ---
enum State

void main()
    State state;
    int x;

    final switch (state)
        x = 5;  // <- can never reach this statement
        case State.init:
        case State.done:

    assert(x == 5);  // throws

I've run into this while adding some logging to my code. By accident I've added
a print statement right above the case statements inside a final switch, and
was puzzled why my code didn't want to log out any information.

The above code is clearly an error and I think the compiler should disallow or
at least warn about the unreachable statement.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to