Commit 5d96dcfc authored by Luca Bruno's avatar Luca Bruno

analyzer: Fix critical when catch clause does not catch an ErrorType

Based on patch by Severin Heiniger.

Fixes bug 670806.
parent 227769b7
......@@ -117,6 +117,11 @@ public class Vala.CatchClause : CodeNode {
checked = true;
if (error_type != null) {
if (!(error_type is ErrorType)) {
Report.error (source_reference, "clause must catch a valid error type, found `%s' instead".printf (error_type.to_string ()));
error = true;
}
if (variable_name != null) {
error_variable = new LocalVariable (error_type.copy (), variable_name);
......@@ -131,7 +136,6 @@ public class Vala.CatchClause : CodeNode {
}
error_type.check (context);
body.check (context);
return !error;
......
......@@ -943,7 +943,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
for (int i = catch_clauses.size - 1; i >= 0; i--) {
var catch_clause = catch_clauses[i];
if (catch_clause.error_type != null) {
var error_type = catch_clause.error_type as ErrorType;
var error_type = (ErrorType) catch_clause.error_type;
jump_stack.add (new JumpTarget.error_target (new BasicBlock (), catch_clause, catch_clause.error_type.data_type as ErrorDomain, error_type.error_code, null));
} else {
jump_stack.add (new JumpTarget.error_target (new BasicBlock (), catch_clause, null, null, null));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment