Commit Graph
17 Commits
Author SHA1 Message Date
Matouš Jan FialkaandGitHub c38876b46f Space Lua: Improve numeric types semantics (#1803)
* Space Lua: Improve numeric types semantics

Add numeric result normalization for arithmetic operations:

* Integer operations preserve int type, collapse -0 to +0
* Float operations preserve float type, maintain -0.0
* Division always produces float results

Fix for-loop variable type tracking:

* Loop variable type determined by start/step parameters
* Integer loops produce integer variables
* Float/mixed loops produce float-tagged variables

Implement table key normalization:

* Integer-valued floats (1.0, 2.0) normalize to integer keys
* All zero variants (0, 0.0, -0.0) map to same key
* Non-integer floats (1.5) remain distinct keys

Add tests for:

* Arithmetic type preservation across operators
* For-loop type modes (int/float/mixed)
* Table key equivalence and normalization
* Edge cases with zero, -0.0, and special values
* Standard library `type` and `math.type`

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Code refactor and deduplication

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-02-02 15:52:03 +01:00
Matouš Jan FialkaandGitHub e5b4c8feb2 Space Lua: Refactor control flow signals (#1794)
* Space Lua: Refactor control flow signals

Removes "return throws an exception" failure mode. @zef :)

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove unused function

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove another unused function

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

* Remove unused `LuaBreak`/`LuaReturn` exception control flow

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>

---------

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2026-01-29 08:07:26 +01:00
Zef Hemel 2e469ba3ea Lua: table.select API 2026-01-27 09:00:37 +01:00
Zef Hemel 63734ee231 Lua: table.find can now take a nil table and not fail (convenient for
queries)
2026-01-08 15:00:35 +01:00
Zef Hemel 8395d2ab63 Propagate errors (e.g. when disabled) for proxy fetch 2025-11-19 14:57:32 +01:00
Matouš Jan FialkaandGitHub 3b0c38d72d Space Lua: Perf improvements (#1666)
* Add result-or-promise (RP) exec model to interpreter (async-first).
* Add centralized table property access with fast misses.
* Update table string keys to be object map.
* Update error contexts to be more consistent and precise.
* Update evaluator to return either values or _Promises_.
* Update func calls, unary and bin operations, and expression lists.
* Update _stdlib_ to the changes and improve errors.
* Add tests to validate async control flow and error contexts.
* Add dedicated benches that isolate the _runtime_ from parsing.
2025-11-10 13:23:32 +01:00
Zef Hemel 125c11721a New Share, Library, Repositories support 2025-11-07 16:28:20 +01:00
Zef Hemel 7cec9b6121 Lua: introduce net.* APIs and deprecate http.request in favor of new
net.proxyFetch API

Introduces foundation support for URIs (net.readURI, net.writeURI).
2025-11-07 10:51:17 +01:00
Zef Hemel f65abb4704 Lua: start of crypto.* API 2025-11-07 10:49:13 +01:00
Zef Hemel 1b28f04bdf A few refinements for Lua APIs 2025-10-31 17:07:40 +01:00
Matouš Jan FialkaandGitHub b363bd7e59 Fix serious truthiness evaluation flaws. (#1644)
In Lua, only the last expression in an argument list preserves multiple
results and all earlier expressions yield exactly one value (their first).

For example:

```
f(a(), b(), c())
```

where

```
a -> (1,2)
b -> (3,4)
c -> (5,6)
```

becomes

```
f(1, 3, 5, 6)
```

which matches Lua behaviour (tested in version 5.4).

Changes:

* Function argument lists keep multiple results only from the last
  argument.

* Fixes failing truthiness tests (`true and ret_one_two()`).

Sidenote: the `truthiness_test.lua` was not called at all because of
my obvious copy/paste typo (the `arithmetical_test.lua` was called twice
instead; now fixed too and both test suites pass ok).
2025-10-20 17:34:45 +02:00
Matouš Jan FialkaandGitHub cb4f392c05 Add huge constant and type() function to the math API (#1632)
Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-16 08:27:56 +02:00
Matouš Jan FialkaandGitHub aa1e61b646 Space Lua: Add load function (#1631)
* Add `load` Lua builtin

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
2025-10-16 08:19:37 +02:00
Zef Hemel 3fa9c82add Fixes #1598
Lua: Implements %u in os.date()
2025-10-10 09:11:14 +02:00
Zef Hemel 18e78e5006 Lua: fix key deletion in tables 2025-10-09 09:19:58 +02:00
Zef Hemel d63c7e49a7 Disable js.import tests for now 2025-09-29 15:56:41 +02:00
Zef Hemel f4336bf09f Code restructuring: eliminated the top-level lib/ directory 2025-09-23 17:00:34 +02:00