return left.is_non_null () && right.is_non_null ();
}
+ bool in_assert () {
+ CodeNode expr = this;
+ while (expr != null && !(expr is MethodCall && ((MethodCall) expr).is_assert)) {
+ expr = expr.parent_node;
+ }
+ return (expr != null);
+ }
+
public override bool check (SemanticAnalyzer analyzer) {
if (checked) {
return !error;
// some expressions are not in a block,
// for example, expressions in method contracts
- if (analyzer.current_symbol is Block
+ //
+ // also don't convert expressions in asserts to not execute
+ // assert expressions when disabled on the C level and
+ // avoid unusable assertion messages
+ // 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 ()
&& (operator == BinaryOperator.AND || operator == BinaryOperator.OR)) {
// convert conditional expression into if statement
// required for flow analysis and exception handling
public bool is_yield_expression { get; set; }
+ public bool is_assert { get; private set; }
+
public Expression _call;
private List<Expression> argument_list = new ArrayList<Expression> ();
if (ma.inner != null) {
target_object_type = ma.inner.value_type;
}
+
+ if (ma.symbol_reference != null && ma.symbol_reference.get_attribute ("Assert") != null) {
+ this.is_assert = true;
+ }
}
var mtype = call.value_type;
public static void warn_if_fail (bool expr);
public static void warn_if_reached ();
+ [Assert]
public static void assert (bool expr);
[NoReturn]
public static void assert_not_reached ();