diff --git a/src/aro/Parser.zig b/src/aro/Parser.zig index ef39f075..9a956b0e 100644 --- a/src/aro/Parser.zig +++ b/src/aro/Parser.zig @@ -6447,6 +6447,8 @@ fn landExpr(p: *Parser) Error!Result { if (try lhs.adjustTypes(tok, &rhs, p, .boolean_logic)) { const res = lhs.val.toBool(p.comp) and rhs.val.toBool(p.comp); lhs.val = Value.fromBool(res); + } else { + lhs.val.boolCast(p.comp); } try lhs.boolRes(p, .bool_and_expr, rhs); } @@ -6516,6 +6518,8 @@ fn eqExpr(p: *Parser) Error!Result { const op: std.math.CompareOperator = if (tag == .equal_expr) .eq else .neq; const res = lhs.val.compare(op, rhs.val, p.comp); lhs.val = Value.fromBool(res); + } else { + lhs.val.boolCast(p.comp); } try lhs.boolRes(p, tag, rhs); } @@ -6545,6 +6549,8 @@ fn compExpr(p: *Parser) Error!Result { }; const res = lhs.val.compare(op, rhs.val, p.comp); lhs.val = Value.fromBool(res); + } else { + lhs.val.boolCast(p.comp); } try lhs.boolRes(p, tag, rhs); } diff --git a/test/cases/binary expressions.c b/test/cases/binary expressions.c index c628c61a..2b008d3f 100644 --- a/test/cases/binary expressions.c +++ b/test/cases/binary expressions.c @@ -83,6 +83,9 @@ _Static_assert((-1 ^ 0) == -1, ""); _Static_assert((-1 ^ -1) == 0, ""); _Static_assert((-2 ^ 2) == -4, ""); +_Static_assert(2.0||(2.0 == 2.0), ""); +_Static_assert(2.0||(3.0 > 2.0), ""); +_Static_assert(2.0||(2.0 && 2.0), ""); #define EXPECTED_ERRORS "binary expressions.c:3:7: error: invalid operands to binary expression ('long' and 'float')" \ "binary expressions.c:6:13: error: invalid operands to binary expression ('char' and 'int *')" \