From 8853546dde97e14f38b8e4558a8af6b61365edfc Mon Sep 17 00:00:00 2001 From: shin4141 <128954611+shin4141@users.noreply.github.com> Date: Fri, 14 Aug 2026 16:13:02 +0900 Subject: [PATCH] Fix String.toInt near max safe integer --- src/Gren/Kernel/String.js | 2 +- tests/src/Test/String.gren | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gren/Kernel/String.js b/src/Gren/Kernel/String.js index 6d28f51..9b83895 100644 --- a/src/Gren/Kernel/String.js +++ b/src/Gren/Kernel/String.js @@ -214,7 +214,7 @@ function _String_toInt(str) { if (code < 0x30 || 0x39 < code) { return __Maybe_Nothing; } - total = 10 * total + code - 0x30; + total = 10 * total + (code - 0x30); } return i == start diff --git a/tests/src/Test/String.gren b/tests/src/Test/String.gren index c98a660..4fb0b63 100644 --- a/tests/src/Test/String.gren +++ b/tests/src/Test/String.gren @@ -76,6 +76,10 @@ tests = , badInt "1e31" , badInt "123a" , goodInt "0123" 123 + , goodInt "9007199254740944" 9007199254740944 + , goodInt "9007199254740945" 9007199254740945 + , goodInt "9007199254740991" 9007199254740991 + , goodInt "-9007199254740991" -9007199254740991 , badInt "0x001A" , badInt "0x001a" , badInt "0xBEEF"