On 03/02/2015 10:58 PM, Andre wrote:
Hi,

I am little bit confused. I am copied the switch example from lex.html
and expected that case 6 will lead to a syntax error due to the missing
break statement. But the example compiles without error (C:>dmd app)

I tried 3 different dmd version, also the newest beta.

Kind regards
André

import std.stdio: writeln;

void main()
{

int number;
string message;

switch (number)
{
   default:    // valid
     throw new Exception("unknown number");

   case 3:     // valid
     message ~= "three ";
     break;

   case 5:     // valid
     message ~= "five ";
     goto case;

   case 6:     // ERROR: implicit fall-through
     message ~= "six ";

   case 1:     // valid
   case 2:     // valid
     message = "one or two";
}

}

Compile with -w command line switch. :)

Ali

Reply via email to