Files
plainleaf/client/space_lua
Matouš Jan FialkaandGitHub e91bec71c0 Fix Lua arithmetic model (#1587)
This patch fixes the Lua arithmetic model at parser level only. Runtime
level fixtures are left for future work.

MOTIVATION

Space Lua treats all numbers as IEEE-754 doubles (JS semantics), so it
preserves negative zero. Lua uses integers and floats. The literal "-0"
in Lua is parsed as unary minus applied to the integer literal "0",
which yields the integer "0" (no sign). This difference flips the sign
of the divisor in "1/-0" and "-1/-0". Although it could be fixed without
touching the parser by changing only unary minus evaluation, this commit
goes a little further and provides integer vs float differenciating at
the parser level as well uses it to fix the unary minus evaluation.

Extensive tests are added to test this exact change works and the Space
Lua arithmetic model is aligned with Lua. Note that things like `-(expr)`
in general may still produce results inconsistent with Lua. This cannot
be fixed at parser level and must be fixed at runtime level which will
need far more complex change to the Space Lua interpreter code. Therefor
these cases we omitted from the tests.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-03 16:31:00 +02:00
..
2025-09-29 15:56:41 +02:00
2025-10-03 16:31:00 +02:00
2025-10-03 16:31:00 +02:00
2025-10-03 16:31:00 +02:00
2025-10-03 16:31:00 +02:00
2025-10-01 17:14:54 +02:00