tinymux/tests/luajit
Stephen Dennis 5b497df7c1 fix(lua/jit): tonumber fast path must reject int64-overflowing literals (#1866)
#1866's proven-integral fast path upgrades tonumber(arg) to CALL_INT when
the argument is an all-digit SCONST.  But Lua 5.4 returns a FLOAT, not an
integer, when a decimal literal overflows int64:

  tonumber("9223372036854775808")    -> 9.2e18   (INT64_MAX + 1)
  tonumber("99999999999999999999999999") -> 1e26

For those, CALL_INT sees lua_isinteger == false and post-entry declines
loud (#-1 LUA ERROR) where the interpreter answers the float — a
compiled-vs-interpreter divergence, exactly the class the seam corpus
guards, newly introduced by the fast path.

lua_tonumber_arg_is_integral now bounds the significant-digit count:
INT64_MAX has 19 digits, so <= 18 significant digits always fits and is
guaranteed integral; 19+ falls back to CALL_VAL, which preserves the
typed float.  Conservative (some in-range 19-digit values take the slower
CALL_VAL path) but sound — same significant-digit bound as the CIDR
prefix guard.  tonumber("17") still executes native.

tests/luajit gains two EXEC pins (INT64_MAX+1 and a 26-digit literal);
both FAIL against the pre-fix engine (post-entry decline) and pass after.
Harness: 228 chunks, 0 divergences, 0 exec_post_entry.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 09:20:59 -06:00
..
.gitignore test(luajit): keep a failed run's workdir instead of deleting it (#1446) (#1450) 2026-07-26 16:34:00 -06:00
bench.sh test(lua/jit): throughput bench, interpreter vs compiled (#1741) 2026-07-28 20:19:07 -06:00
run.sh fix(lua/jit): tonumber fast path must reject int64-overflowing literals (#1866) 2026-07-31 09:20:59 -06:00