From 5ea81fe4e0656d1cb24d4003d4d7e061dc54d5c7 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 24 Apr 2026 19:57:24 +0000 Subject: [PATCH] =?UTF-8?q?lua:=20scoreboard=20iter=20=E2=80=94=20return;?= =?UTF-8?q?=20trailing-semi,=20collectgarbage/setfenv/getfenv/T=20stubs;?= =?UTF-8?q?=20all=20runnable=20tests=20reach=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lua/parser.sx | 1 + lib/lua/runtime.sx | 19 +++++++++++ lib/lua/scoreboard.json | 72 ++++++++++++++++------------------------- lib/lua/scoreboard.md | 42 +++++++++++------------- plans/lua-on-sx.md | 1 + 5 files changed, 68 insertions(+), 67 deletions(-) diff --git a/lib/lua/parser.sx b/lib/lua/parser.sx index 6d10e368..9611ea45 100644 --- a/lib/lua/parser.sx +++ b/lib/lua/parser.sx @@ -733,6 +733,7 @@ (check-tok? "eof" nil) (at-op? ";"))) (set! exps (parse-explist))) + (when (at-op? ";") (advance-tok!)) (list (quote lua-return) exps)))))) (define parse-assign-or-call diff --git a/lib/lua/runtime.sx b/lib/lua/runtime.sx index 99371195..59acfd01 100644 --- a/lib/lua/runtime.sx +++ b/lib/lua/runtime.sx @@ -1517,3 +1517,22 @@ (dict-set! debug "getupvalue" (fn (&rest args) nil)) (dict-set! debug "setupvalue" (fn (&rest args) nil)) (dict-set! __package-loaded "debug" debug) + +;; collectgarbage stubs + env stubs +(define + lua-collectgarbage + (fn (&rest args) + (cond + ((= (len args) 0) 0) + ((= (first args) "count") 0) + ((= (first args) "collect") 0) + (else 0)))) + +(define collectgarbage lua-collectgarbage) + +;; setfenv/getfenv — Lua 5.1 env manipulation. Stubs. +(define setfenv (fn (&rest args) (if (> (len args) 0) (first args) nil))) +(define getfenv (fn (&rest args) _G)) + +;; T — debug/testC placeholder for tests that check it conditionally +(define T nil) diff --git a/lib/lua/scoreboard.json b/lib/lua/scoreboard.json index 29dc0907..0e17f3af 100644 --- a/lib/lua/scoreboard.json +++ b/lib/lua/scoreboard.json @@ -1,8 +1,8 @@ { "totals": { "pass": 0, - "fail": 15, - "timeout": 1, + "fail": 14, + "timeout": 2, "skip": 8, "total": 24, "runnable": 16, @@ -11,35 +11,19 @@ "top_failure_modes": [ [ "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - 8 + 11 + ], + [ + "timeout", + 2 ], [ "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio", 2 ], - [ - "timeout", - 1 - ], - [ - "undefined symbol: collectgarbage\\", - 1 - ], - [ - "parse error", - 1 - ], - [ - "undefined symbol: setfenv\\", - 1 - ], [ "arith type error", 1 - ], - [ - "undefined symbol: T\\", - 1 ] ], "results": [ @@ -59,19 +43,19 @@ "name": "attrib.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 5747 + "ms": 5584 }, { "name": "big.lua", "status": "timeout", "reason": "per-test timeout", - "ms": 8007 + "ms": 8004 }, { "name": "calls.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 4595 + "ms": 4599 }, { "name": "checktable.lua", @@ -81,9 +65,9 @@ }, { "name": "closure.lua", - "status": "fail", - "reason": "undefined symbol: collectgarbage\\", - "ms": 6175 + "status": "timeout", + "reason": "per-test timeout", + "ms": 8007 }, { "name": "code.lua", @@ -94,8 +78,8 @@ { "name": "constructs.lua", "status": "fail", - "reason": "parse error", - "ms": 2589 + "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", + "ms": 4056 }, { "name": "db.lua", @@ -107,13 +91,13 @@ "name": "errors.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 2997 + "ms": 3049 }, { "name": "events.lua", "status": "fail", - "reason": "undefined symbol: setfenv\\", - "ms": 6803 + "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", + "ms": 6705 }, { "name": "files.lua", @@ -131,13 +115,13 @@ "name": "literals.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 1783 + "ms": 1734 }, { "name": "locals.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 1623 + "ms": 1510 }, { "name": "main.lua", @@ -149,43 +133,43 @@ "name": "math.lua", "status": "fail", "reason": "arith type error", - "ms": 3864 + "ms": 3820 }, { "name": "nextvar.lua", "status": "fail", - "reason": "undefined symbol: T\\", - "ms": 6725 + "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", + "ms": 6758 }, { "name": "pm.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 5622 + "ms": 5586 }, { "name": "sort.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio", - "ms": 1158 + "ms": 1121 }, { "name": "strings.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 3811 + "ms": 3652 }, { "name": "vararg.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 2111 + "ms": 2009 }, { "name": "verybig.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio", - "ms": 563 + "ms": 527 } ] } \ No newline at end of file diff --git a/lib/lua/scoreboard.md b/lib/lua/scoreboard.md index c4e3a9c9..a0832da4 100644 --- a/lib/lua/scoreboard.md +++ b/lib/lua/scoreboard.md @@ -1,18 +1,14 @@ # Lua-on-SX conformance scoreboard **Pass rate:** 0/16 runnable (0.0%) -fail=15 timeout=1 skip=8 total=24 +fail=14 timeout=2 skip=8 total=24 ## Top failure modes -- **8x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ +- **11x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ +- **2x** timeout - **2x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio -- **1x** timeout -- **1x** undefined symbol: collectgarbage\ -- **1x** parse error -- **1x** undefined symbol: setfenv\ - **1x** arith type error -- **1x** undefined symbol: T\ ## Per-test results @@ -20,25 +16,25 @@ fail=15 timeout=1 skip=8 total=24 |---|---|---|---:| | all.lua | skip | driver uses dofile to chain other tests | 0 | | api.lua | skip | requires testC (C debug library) | 0 | -| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5747 | -| big.lua | timeout | per-test timeout | 8007 | -| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4595 | +| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5584 | +| big.lua | timeout | per-test timeout | 8004 | +| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4599 | | checktable.lua | skip | internal debug helpers | 0 | -| closure.lua | fail | undefined symbol: collectgarbage\ | 6175 | +| closure.lua | timeout | per-test timeout | 8007 | | code.lua | skip | bytecode inspection via debug library | 0 | -| constructs.lua | fail | parse error | 2589 | +| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4056 | | db.lua | skip | debug library | 0 | -| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2997 | -| events.lua | fail | undefined symbol: setfenv\ | 6803 | +| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3049 | +| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6705 | | files.lua | skip | io library | 0 | | gc.lua | skip | collectgarbage / finalisers | 0 | -| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1783 | -| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1623 | +| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1734 | +| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1510 | | main.lua | skip | standalone interpreter driver | 0 | -| math.lua | fail | arith type error | 3864 | -| nextvar.lua | fail | undefined symbol: T\ | 6725 | -| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5622 | -| sort.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1158 | -| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3811 | -| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2111 | -| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 563 | +| math.lua | fail | arith type error | 3820 | +| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6758 | +| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5586 | +| sort.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1121 | +| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3652 | +| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2009 | +| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 527 | diff --git a/plans/lua-on-sx.md b/plans/lua-on-sx.md index 142551bb..9435dfcd 100644 --- a/plans/lua-on-sx.md +++ b/plans/lua-on-sx.md @@ -82,6 +82,7 @@ Each item: implement → tests → tick box → update progress log. _Newest first. Agent appends on every commit._ +- 2026-04-24: lua: scoreboard iteration — parser consumes trailing `;` after `return`; added `collectgarbage`/`setfenv`/`getfenv`/`T` stubs. All parse errors and undefined-symbol failures eliminated — every runnable test now executes deep into the script. Failure mix: **11× assertion failed**, 2× timeout, 2× call-non-fn, 1× arith. Still 0/16 pass but the remaining work is substantive (stdlib fidelity vs the exact PUC-Rio assertions). - 2026-04-24: lua: scoreboard iteration — trailing-dot number literals (`5.`), preload stdlibs in `package.loaded` (`string`/`math`/`table`/`io`/`os`/`coroutine`/`package`/`_G`), `arg` stub, `debug` module stub. Assertion-failure count 4→**8**, parse errors 3→**1**, call-non-fn stable, module-not-found gone. - 2026-04-24: lua: scoreboard iteration — **vararg `...` transpile**. Parser already emitted `(lua-vararg)`; transpile now: (a) binds `__varargs` in function body when `is-vararg`, (b) emits `__varargs` for `...` uses; `lua-varargs`/`lua-spread-last-multi` runtime helpers spread multi in last call-arg and last table-pos positions. Eliminated all 6× "transpile: unsupported" failures; top-5 now all real asserts. 353 unit tests. - 2026-04-24: lua: scoreboard iteration — added `rawget`/`rawset`/`rawequal`/`rawlen`, `loadstring`/`load`, `select`, `assert`, `_G`, `_VERSION`. Failure mix now 6×vararg-transpile / 4×real-assertion / 3×parse / 2×call-non-fn / 1×timeout (was 14 parse + 1 print undef at baseline); tests now reach deep into real assertions. Still 0/16 runnable — next targets: vararg transpile, goto, loadstring-compile depth. 347 unit tests.