Release D 2.076.0

nkm1 via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Sep 4 07:05:19 PDT 2017


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.


More information about the Digitalmars-d-announce mailing list