Saaa wrote:
What kind of fall-throughs were these?

A:

case value1:
case value2:
case valueN:
    code1();
    break;

B:

case value1:
    code1();
case value2:
    code2();
    break;
The solution is to forbid fallthrough, and change the switch syntax:

switch(value) {
  case 1:
  case 2:
// something
break;
}

gives: Error, missing break at the end of case1.

But:

switch(value) {
  case 1, 2:
// something
break;
}

works as expected.

What's wrong with that?

Doesn't support B :)

How about a warning instead?

The idea is that it not supporting B is something good.

An error is ok, and if you want to translate C code then it's really easy to change the code to not give errors.

Reply via email to