Sample code:
import std.stdio;
void foo() {
writeln(__FUNCTION__);
}
void bar() {
writeln(__FUNCTION__);
}
void fun(int i) {
int n = 3;
switch (i) {
while (n --> 0)
case 0:
case 1:
foo();
bar();
default:
writeln("default");
}
}
void main() {
fun(1);
}
The fun function ought to be parsed as:
void fun(int i) {
int n = 3;
switch (i) {
while (n --> 0) {
case 0:
case 1:
foo();
bar();
}
default:
writeln("default");
}
}
The control flow falls through into the default case without a goto default. This is supposed to be an error in D, but DMD accepts it in this case.
Comment #1 by robert.schadek — 2024-12-13T19:20:41Z