[vala] Fix side effects in assertions



commit 43a73a0d98424703f3b9af6cf762b521a10aa66a
Author: Jürg Billeter <j bitron ch>
Date:   Mon Jul 12 19:45:57 2010 +0200

    Fix side effects in assertions
    
    Fixes bug 624129.

 vala/valabinaryexpression.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 8e813e2..1ae6175 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -149,6 +149,10 @@ public class Vala.BinaryExpression : Expression {
 		return (expr != null);
 	}
 
+	bool pure_and_in_assert () {
+		return is_pure () && in_assert ();
+	}
+
 	public override bool check (SemanticAnalyzer analyzer) {
 		if (checked) {
 			return !error;
@@ -165,7 +169,7 @@ public class Vala.BinaryExpression : Expression {
 		// reachability analysis and error handling should never be
 		// necessary for assertion expressions, so it is ok to avoid
 		// the split
-		if (analyzer.current_symbol is Block && !in_assert ()
+		if (analyzer.current_symbol is Block && !pure_and_in_assert ()
 		    && (operator == BinaryOperator.AND || operator == BinaryOperator.OR)) {
 			// convert conditional expression into if statement
 			// required for flow analysis and exception handling



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