From 85c2aaf0a426158e96261ddace4d5287c646ba58 Mon Sep 17 00:00:00 2001 From: misomosi Date: Sun, 28 Jun 2026 19:25:02 -0400 Subject: [PATCH 1/2] Use libtommath API for counting bits --- src/big_int.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/big_int.cpp b/src/big_int.cpp index 4f20f2ad9..a8ea2079b 100644 --- a/src/big_int.cpp +++ b/src/big_int.cpp @@ -296,8 +296,7 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success gb_internal bool big_int_can_be_represented_in_64_bits(BigInt const *x) { - int bits_used = (x->used-1) * MP_DIGIT_BIT; - return bits_used <= 64; + return mp_count_bits(x) <= 64; } gb_internal u64 big_int_to_u64(BigInt const *x) { From 5be99bf1c2ff63633a1e28be79f7e5df84eb90a5 Mon Sep 17 00:00:00 2001 From: misomosi Date: Sun, 28 Jun 2026 19:25:22 -0400 Subject: [PATCH 2/2] Add missing check_is_expressible --- src/check_expr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 79e1154a1..5a95a5dbb 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3421,6 +3421,8 @@ gb_internal void check_shift(CheckerContext *c, Operand *x, Operand *y, Ast *nod x->expr = node; x->value = exact_value_shift(be->op.kind, exact_value_to_integer(x->value), exact_value_to_integer(y->value)); + check_is_expressible(c, x, x->type); + return; }