aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-12-10 16:12:54 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2025-12-10 16:12:54 +0100
commit503269b9bf896d4263c90e76ce65dbfc1fadb27e (patch)
tree1a6e16aaff123fdc99b15ab8d00a9405fa01830c /src/check_expr.cpp
parent72d65603eb513d6788a21f02bc211b662c6102e8 (diff)
parent8610acb48f2fd0c9d280c9a7973caf8db4143cf9 (diff)
Merge branch 'master' into pr/5882
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 418fb5378..470290d49 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2116,9 +2116,6 @@ gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue i
}
return in_value.kind == ExactValue_String;
} else if (is_type_integer(type) || is_type_rune(type)) {
- if (in_value.kind == ExactValue_Bool) {
- return false;
- }
ExactValue v = exact_value_to_integer(in_value);
if (v.kind != ExactValue_Integer) {
return false;
@@ -4172,7 +4169,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ
default:
if (is_ise_expr(be->left)) {
// Evalute the right before the left for an '.X' expression
- check_expr_or_type(c, y, be->right, type_hint);
+ check_expr_or_type(c, y, be->right, token_is_comparison(op.kind) ? nullptr : type_hint);
if (can_use_other_type_as_type_hint(use_lhs_as_type_hint, y->type)) { // RHS in this case
check_expr_or_type(c, x, be->left, y->type);
@@ -4184,7 +4181,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ
if (can_use_other_type_as_type_hint(use_lhs_as_type_hint, x->type)) {
check_expr_with_type_hint(c, y, be->right, x->type);
} else {
- check_expr_with_type_hint(c, y, be->right, type_hint);
+ check_expr_with_type_hint(c, y, be->right, token_is_comparison(op.kind) ? nullptr : type_hint);
}
}
break;
@@ -8148,6 +8145,7 @@ gb_internal ExprKind check_call_expr_as_type_cast(CheckerContext *c, Operand *op
if (operand->mode != Addressing_Invalid) {
update_untyped_expr_type(c, arg, t, false);
+ check_representable_as_constant(c, operand->value, t, &operand->value);
}
break;
}