From c580e1af93965a5bf193ae44cc6a02e3b7a5c9af Mon Sep 17 00:00:00 2001 From: kalsprite Date: Wed, 19 Aug 2026 11:29:28 -0700 Subject: [PATCH] big_int: base prefix iwth only seperateors and no digits --- src/big_int.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/big_int.cpp b/src/big_int.cpp index 1d81a0483..0d38f0ab1 100644 --- a/src/big_int.cpp +++ b/src/big_int.cpp @@ -218,6 +218,7 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success defer (big_int_dealloc(&digit)); isize i = 0; + isize digit_count = 0; for (; i < len; i++) { Rune r = cast(Rune)text[i]; @@ -241,12 +242,19 @@ gb_internal void big_int_from_string(BigInt *dst, String const &s, bool *success *success = false; } break; + } else { + digit_count += 1; } big_int_from_u64(&digit, v); big_int_mul_eq(dst, &b); big_int_add_eq(dst, &digit); } + if (digit_count == 0) { + // a base prefix with only digit separators after it, `0x_`, has no digits at all + *success = false; + return; + } if (i < len && (text[i] == 'e' || text[i] == 'E')) { i += 1; if (base != 10) {