]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Propagate uncaught errors in try statements
authorDidier 'Ptitjes <ptitjes@free.fr>
Fri, 8 May 2009 16:56:20 +0000 (18:56 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 6 Jun 2009 18:48:40 +0000 (20:48 +0200)
Fixes bug 579388.

Signed-off-by: Didier 'Ptitjes <ptitjes@free.fr>
vala/valatrystatement.vala

index fd43dde5ff628a30d803e97fe7e4277ab511dd74..715ab7d8dc5165e9ccebe572043db940806be8fa 100644 (file)
@@ -96,14 +96,38 @@ public class Vala.TryStatement : CodeNode, Statement {
 
                body.check (analyzer);
 
+               var error_types = new Gee.ArrayList<DataType> ();
+               foreach (DataType body_error_type in body.get_error_types ()) {
+                       error_types.add (body_error_type);
+               }
+
+               var handled_error_types = new Gee.ArrayList<DataType> ();
                foreach (CatchClause clause in catch_clauses) {
+                       foreach (DataType body_error_type in error_types) {
+                               if (body_error_type.compatible (clause.error_type)) {
+                                       handled_error_types.add (body_error_type);
+                               }
+                       }
+                       foreach (DataType handled_error_type in handled_error_types) {
+                               error_types.remove (handled_error_type);
+                       }
+                       handled_error_types.clear ();
+
                        clause.check (analyzer);
+                       foreach (DataType body_error_type in clause.body.get_error_types ()) {
+                               error_types.add (body_error_type);
+                       }
                }
 
                if (finally_body != null) {
                        finally_body.check (analyzer);
+                       foreach (DataType body_error_type in finally_body.get_error_types ()) {
+                               error_types.add (body_error_type);
+                       }
                }
 
+               add_error_types (error_types);
+
                return !error;
        }
 }