[SpaceLua] Use luaFormatNumber for number-to-string coercion in .. and table.concat

Replace raw `String(v)` calls with `luaFormatNumber` in the concatenation
operator and `table.concat`, so that floats are formatted according to Lua
semantics rather than JavaScript's. This fixes cases like `10.8*22..""`
producing `237.60000000000002` instead of `237.6`, and ensures
integer-valued floats carry the `.0` suffix as Lua requires.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
This commit is contained in:
Matouš Jan Fialka
2026-02-20 07:31:32 +01:00
parent 3ddfab51e8
commit d2eb8fe6ec
4 changed files with 67 additions and 4 deletions
+3 -2
View File
@@ -5,6 +5,7 @@ import {
luaCall,
type LuaEnv,
luaEquals,
luaFormatNumber,
luaGet,
LuaMultiRes,
LuaRuntimeError,
@@ -77,10 +78,10 @@ export const tableApi = new LuaTable({
return v;
}
if (typeof v === "number") {
return String(v);
return luaFormatNumber(v);
}
if (isTaggedFloat(v)) {
return String(v.value);
return luaFormatNumber(v.value, "float");
}
const ty = typeof v === "object" && v instanceof LuaTable