Otherwise this can result in an infinite loop in FlowAnalyzer.intersect()
Improve source reference for jump out of finally block
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1287
control-flow/switch.vala \
control-flow/switch-enum.vala \
control-flow/switch-string.vala \
+ control-flow/switch-try-finally-throw.test \
control-flow/sideeffects.vala \
control-flow/unassigned-captured-local-variable.test \
control-flow/unassigned-local-block-variable.test \
--- /dev/null
+Invalid Code
+
+errordomain FooError {
+ FAIL
+}
+
+void foo () throws FooError {
+}
+
+void bar (int i) throws Error {
+ switch (i) {
+ case 23:
+ try {
+ } finally {
+ foo ();
+ }
+ break;
+ default:
+ throw new FooError.FAIL ("bar");
+ }
+}
+
+void main () {
+}
stmt.finally_body.accept (this);
+ jump_stack.remove_at (jump_stack.size - 1);
+
if (invalid_block.get_predecessors ().size > 0) {
// don't allow finally blocks with e.g. return statements
- Report.error (stmt.source_reference, "jump out of finally block not permitted");
+ Report.error (stmt.finally_body.source_reference, "jump out of finally block not permitted");
stmt.error = true;
return;
}
- jump_stack.remove_at (jump_stack.size - 1);
jump_stack.add (new JumpTarget.finally_clause (finally_block, current_block));
}