]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix side effects in assertions
authorJürg Billeter <j@bitron.ch>
Mon, 12 Jul 2010 17:45:57 +0000 (19:45 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 12 Jul 2010 17:45:57 +0000 (19:45 +0200)
Fixes bug 624129.

vala/valabinaryexpression.vala

index 8e813e21918b3a95ef89fca786441a9062b0a66e..1ae617594ee058e0ddb3be4b47d1f4cb2e88118d 100644 (file)
@@ -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