sdk
sdk copied to clipboard
[dart2wasm] Execute `finally` blocks crossed by `break` or `continue`
When a try block with a finally block is exited via a break or continue statement, the code in the finally block runs. This mechanism is currently not implemented in dart2wasm.
This causes the following co19 tests to hang due to an await for loop not cancelling the stream subscription on exit:
Language/Statements/Continue/async_loops_t07
Language/Statements/Continue/async_loops_t08
LibTest/async/Stream/Stream.fromFutures_all_t01
LibTest/async/Stream/Stream.fromIterable_all_t01
LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t01
LibTest/async/StreamController/stream_all_A01_t01
Repro:
void main() {
bool yes = false;
while (true) {
try {
break;
} finally {
yes = true;
}
}
print(yes);
}
Prints 'true' when run with AOT/JIT, prints 'false' with dart2wasm.
Slightly more complicated example that tests changing control flow in finally:
void main() {
for (var i = 0; i < 5; i += 1) {
try {
try {
try {
break;
} catch (_) {
print("A");
}
} finally {
throw "foo";
}
} catch (_) {
print("B");
}
}
}
https://dart-review.googlesource.com/c/sdk/+/262240