diff options
| author | gingerBill <bill@gingerbill.org> | 2022-06-26 13:13:07 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-06-26 13:13:07 +0100 |
| commit | abe122ecb7ef33cff52fd072514de5ad40538bc2 (patch) | |
| tree | 9b16ab5dbca68feeb711ad74dda953dc4315bae2 | |
| parent | f8744d87b02f1db75010eb9856bdad9d31fa7b45 (diff) | |
Implement #1859
| -rw-r--r-- | src/check_expr.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 58972d2cf..b42301cd6 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3249,8 +3249,14 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint return; } - - if (!are_types_identical(x->type, y->type)) { + if ((op.kind == Token_CmpAnd || op.kind == Token_CmpOr) && + is_type_boolean(x->type) && is_type_boolean(y->type)) { + // NOTE(bill, 2022-06-26) + // Allow any boolean types within `&&` and `||` + // This is an exception to all other binary expressions since the result + // of a comparison will always be an untyped boolean, and allowing + // any boolean between these two simplifies a lot of expressions + } else if (!are_types_identical(x->type, y->type)) { if (x->type != t_invalid && y->type != t_invalid) { gbString xt = type_to_string(x->type); |