[Space Lua] Miscellaneous bug fixes and improvements#1844
Merged
zefhemel merged 16 commits intosilverbulletmd:mainfrom Feb 25, 2026
Merged
[Space Lua] Miscellaneous bug fixes and improvements#1844zefhemel merged 16 commits intosilverbulletmd:mainfrom
zefhemel merged 16 commits intosilverbulletmd:mainfrom
Conversation
…` 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>
…tack frame `tostring()` was delegating to `luaToString()` which calls `__tostring` with a dead stack frame, breaking metamethods that call back into globals. Now `tostringFunction` receives the live stack frame, looks up `__tostring` via `rawGet`, calls it through `luaCall` with the live frame, and validates the return is a string. Also add tests covering the basic case, the nested-call case, and the error path for a non-string return. Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Implement `table.move(a1, f, e, t [,a2])`. The implementation copies elements `a1[f..e]` to `a2[t..t+(e-f)]` defaulting `a2` to `a1` and returning `a2` as follows: * empty ranges (`e < f`) are "no-op", * for in-table copies where `t > f` loop backwards to prevent unread source slots from being clobbered before they are read (note: the only case where overlap is destructive, * cross-table copies always run forwards since there is no aliasing. Add test suite that covers: * non-overlapping copies, * cross-table copies, * both overlap directions, * same position identity, * empty ranges, and * single element moves. Each of the above is tested with both scalar and nested-table values. Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Returning `1` when the comparator yields `false`/`nil` declares `a > b` for equal elements. `asyncQuickSort` tolerates this today but any future sort algorithm change could corrupt results. Changed to `0` so ties are neutral. Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
… `String` Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
`table.pack` now routes element writes through `luaSet` so `__newindex` metamethods are honoured, matching the exact Lua 5.4 semantics. The `n` field is still written with `rawSet`, also matching Lua. `table.unpack` now returns an empty `LuaMultiRes` instead of `null` for an empty range `(i > j)`. Returning `null` would inject a single `nil` argument at the call site; an empty `LuaMultiRes` correctly contributes zero values, matching the exact Lua semantics. The global `unpack` shim (for Lua 5.1 compatibility) has been removed from `luaBuildStandardEnv`. Users who need the short alias can set it up in `space-script` with a single line stating `unpack = table.unpack`. Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
zefhemel
approved these changes
Feb 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR in the commits.