From 5e4895e76dc5bb5ee4357037433825907403457e Mon Sep 17 00:00:00 2001 From: Barinzaya Date: Fri, 23 Jan 2026 15:53:29 -0500 Subject: [PATCH] Fixed some issues with `in` and `not_in` on constant `bit_set`s. This addresses two issues: - With a `bit_set` having no underlying type and a non-zero lower bound, `in` and `not_in` were returning incorrect results when done at compile-time. - With a `bit_set` of more than 128 bits, `in` always returns false on values that fall within the upper 64 bits. --- src/check_expr.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 8fdd5372b..d64c733f3 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -4125,15 +4125,19 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ i64 upper = yt->BitSet.upper; if (lower <= key && key <= upper) { - i64 bit = 1ll<mode = Addressing_Constant; x->type = t_untyped_bool; if (op.kind == Token_in) { - x->value = exact_value_bool((bit & bits) != 0); + x->value = exact_value_bool(!big_int_is_zero(&mask)); } else { - x->value = exact_value_bool((bit & bits) == 0); + x->value = exact_value_bool(big_int_is_zero(&mask)); } x->expr = node; return;