Finally block doesn't handle errors from within catch block #11758
Labels
area-vm
Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
closed-duplicate
Closed in favor of an existing report
This issue was originally filed by shailen.tu...@gmail.com
What steps will reproduce the problem?
Type this code in the Editor and run it:
void main() {
try {
try {
throw null;
} catch(e) {
throw null;
} finally {
print('first');
}
} finally {
print('second');
}
}
What is the expected output? What do you see instead?
In the VM this produces the following result:
second
Unhandled exception: Throw of null.
In dart2js (try.dartlang.org), it produces this result:
first
second
Uncaught Throw of null.
The two should produce the same output.
The language spec states that:
If an exception is raised during execution of an on-catch clause, this will transfer control to the handler for the finally clause, causing the finally clause to execute in this case as well.
This suggests that the VM implementation has a bug: the error thrown within the catch block does not lead the subsequent finally clause to execute.
What version of the product are you using? On what operating system?
OSX 10.8.4
Dart SDK version 0.5.20.4_r24275
Please provide any additional information below.
This was first reported on StackOverflow:
http://stackoverflow.com/questions/17553334/understanding-exception-handling-mechanism-control-flow-in-dart
The text was updated successfully, but these errors were encountered: