Given the following code:
function bar() {
throw new Lang.Exception();
}
function foo() {
try {
} catch (ex) {
} finally {
try {
bar();
} catch (ex) {}
System.println("Still ok");
}
System.println("but never gets here");
}
when I call foo(), I get
Still ok
Error: Unexpected Type Error
Details: Failed invoking <symbol>
Stack:
- foo() at bug.mc:13 0x100000dd
Encountered app crash.
I would expect it to execute both System.println calls. I get this behavior whether the initial try throws or not - so adding a throw, or a call to bar into the try at line 5 makes no difference.
Strangely, if I replace the call to bar with "throw new Lang.Exception()", the code works as expected; but if I wrap that throw in a switch statement (something like switch(x){default:throw new Exception();}) , it fails again.
I think the issue is probably related to some of the issues I mentioned here, where various constructs (switch, catch, finally) appear to leave values on the stack; and it seems that throwing an exception doesn't take account of what might be there, and unbalances the stack.