Closed brianush1 closed 1 year ago
this also is valid, but what does this even mean? (it compiles and runs as if the scope guard wasn't there):
void main() {
switch (x)
{
case 1:
break;
scope (exit)
default:
foo();
break;
}
}
void main() {
switch (2)
{
case 1:
break;
if (true) {
writeln("huh");
default:
writeln("ran");
foo();
}
break;
}
}
so, this code prints "ran"... I guess jumping to a switch label acts the same as jumping to a label using goto, which means switch labels can be inside blocks..? and scope (exit)
gets lowered down to a try/finally, so that works out
also, interestingly, if you dump the AST you can see that the break;
statement in your code example is not actually inside the scope (exit)
statement...
compiles fine with DMD, but doesn't parse with libdparse