From: Jürg Billeter Date: Mon, 12 Jul 2010 17:45:57 +0000 (+0200) Subject: Fix side effects in assertions X-Git-Tag: 0.9.3~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43a73a0d98424703f3b9af6cf762b521a10aa66a;p=thirdparty%2Fvala.git Fix side effects in assertions Fixes bug 624129. --- diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala index 8e813e219..1ae617594 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