The following code, with an extra colon in the case statement, compiles without error and produces unexpected results at runtime.
If NUMBER_ZERO is changed to 0 in the case statement, it fails to compile as expected.
enum { NUMBER_ZERO, NUMBER_ONE, NUMBER_TWO }
var n = NUMBER_ZERO;
switch (n) {
case: NUMBER_ZERO: // Note the extra colon
System.println("case NUMBER_ZERO:");
break;
default:
System.println("default:");
break;
}
System.println("after switch(), n = " + n);
Output:
default:after switch(), n = 0
Connect IQ SDK 4.2.1
Visual Studio Code Monkey C v1.0.8
Visual Studio Code Version 1.76.0 on Windows 11