[vala] Propagate uncaught errors in try statements



commit 72bba06647ee22267156fb4f16601aeffa73d0c2
Author: Didier 'Ptitjes <ptitjes free fr>
Date:   Fri May 8 18:56:20 2009 +0200

    Propagate uncaught errors in try statements
    
    Fixes bug 579388.
    
    Signed-off-by: Didier 'Ptitjes <ptitjes free fr>
---
 vala/valatrystatement.vala |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/vala/valatrystatement.vala b/vala/valatrystatement.vala
index fd43dde..715ab7d 100644
--- a/vala/valatrystatement.vala
+++ b/vala/valatrystatement.vala
@@ -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;
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]