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

Alex Parrill <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #11 from Alex Parrill <[email protected]> ---
This also happens if you use return instead of break in the foreach loop, which
should be valid (since return doesn't care about loops):

import std.stdio;
import std.typetuple;

alias SwitchCases = TypeTuple!("a", "b", "c");

int main() {
    string s = "a";

    switch(s) {
        case "special":
            writeln("Special case!");
            return 0;

        foreach(c; SwitchCases) {
            case c:
                writeln(c);
                return 1;
        }

        default:
            writeln("default case");
            return 2;
    }
}

$ rdmd -w ~/test.d
/home/col/test.d(21): Warning: switch case fallthrough - use 'goto default;' if
intended

The switch works properly even if you ignore the warning, and moving the
special case to after the foreach loop removes the warning.

--

Reply via email to