On Friday, 1 September 2017 at 14:03:26 UTC, Martin Nowak wrote:

This release comes with static foreach

Great! I noticed one small issue, though. When compiled with warnings, it warns about unreachable code when static foreach in a switch, for example:


void trySwitch(int x) {
    import std.stdio : writeln;

    SWITCH: final switch (x) {
        static foreach (y; [ 1, 2, 3 ]) {
            case y:
                writeln("found");
                break SWITCH;
        }
    }
}

void main(string[] args) {
    import std.conv : to;

    trySwitch(args.length > 1 ? to!int(args[1]) : 1);
}


Compilation:

$ dmd -wi ./main.d
./main.d(5): Warning: statement is not reachable
./main.d(5): Warning: statement is not reachable
./main.d(5): Warning: statement is not reachable
./main.d(5): Warning: statement is not reachable

It works, though, so I guess it's not a bug per se.

Reply via email to