From 3ec52d45564cda4c456c9aa9a73f0b5234e14ab0 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 24 Apr 2026 22:56:57 +0000 Subject: [PATCH] lua: package.cpath/config/loaders/searchers stubs (attrib.lua past #9) --- lib/lua/runtime.sx | 5 +++++ lib/lua/scoreboard.json | 46 ++++++++++++++++++++++------------------- lib/lua/scoreboard.md | 35 ++++++++++++++++--------------- plans/lua-on-sx.md | 1 + 4 files changed, 49 insertions(+), 38 deletions(-) diff --git a/lib/lua/runtime.sx b/lib/lua/runtime.sx index e0558df5..32c836eb 100644 --- a/lib/lua/runtime.sx +++ b/lib/lua/runtime.sx @@ -1442,6 +1442,11 @@ (dict-set! package "loaded" __package-loaded) (dict-set! package "preload" __package-preload) (dict-set! package "path" "?;?.lua") +(dict-set! package "cpath" "?;?.so") +(dict-set! package "config" "/\n;\n?\n!\n-") +(dict-set! package "loaders" {}) +(dict-set! package "searchers" {}) +(dict-set! package "searchpath" (fn (&rest args) nil)) (define lua-require diff --git a/lib/lua/scoreboard.json b/lib/lua/scoreboard.json index a3804036..9df3322a 100644 --- a/lib/lua/scoreboard.json +++ b/lib/lua/scoreboard.json @@ -1,8 +1,8 @@ { "totals": { "pass": 1, - "fail": 11, - "timeout": 4, + "fail": 12, + "timeout": 3, "skip": 8, "total": 24, "runnable": 16, @@ -15,7 +15,11 @@ ], [ "timeout", - 4 + 3 + ], + [ + "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: module 'C' not found\\\\\\\"\\", + 1 ], [ "undefined symbol: fat\\", @@ -46,20 +50,20 @@ { "name": "attrib.lua", "status": "fail", - "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 6277 + "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: module 'C' not found\\\\\\\"\\", + "ms": 6342 }, { "name": "big.lua", "status": "timeout", "reason": "per-test timeout", - "ms": 8005 + "ms": 8008 }, { "name": "calls.lua", "status": "fail", "reason": "undefined symbol: fat\\", - "ms": 5170 + "ms": 5134 }, { "name": "checktable.lua", @@ -71,7 +75,7 @@ "name": "closure.lua", "status": "timeout", "reason": "per-test timeout", - "ms": 8004 + "ms": 8007 }, { "name": "code.lua", @@ -83,7 +87,7 @@ "name": "constructs.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat", - "ms": 7085 + "ms": 7182 }, { "name": "db.lua", @@ -95,13 +99,13 @@ "name": "errors.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 3327 + "ms": 3464 }, { "name": "events.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 7865 + "ms": 7726 }, { "name": "files.lua", @@ -119,13 +123,13 @@ "name": "literals.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 2110 + "ms": 1940 }, { "name": "locals.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio", - "ms": 1869 + "ms": 1759 }, { "name": "main.lua", @@ -137,19 +141,19 @@ "name": "math.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 4658 + "ms": 4487 }, { "name": "nextvar.lua", - "status": "timeout", - "reason": "per-test timeout", - "ms": 8007 + "status": "fail", + "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", + "ms": 7441 }, { "name": "pm.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 7287 + "ms": 6440 }, { "name": "sort.lua", @@ -161,19 +165,19 @@ "name": "strings.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 4566 + "ms": 4243 }, { "name": "vararg.lua", "status": "fail", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\", - "ms": 2698 + "ms": 2425 }, { "name": "verybig.lua", "status": "pass", "reason": "", - "ms": 666 + "ms": 622 } ] } \ No newline at end of file diff --git a/lib/lua/scoreboard.md b/lib/lua/scoreboard.md index 4f197a5d..555038bf 100644 --- a/lib/lua/scoreboard.md +++ b/lib/lua/scoreboard.md @@ -1,12 +1,13 @@ # Lua-on-SX conformance scoreboard **Pass rate:** 1/16 runnable (6.2%) -fail=11 timeout=4 skip=8 total=24 +fail=12 timeout=3 skip=8 total=24 ## Top failure modes - **8x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ -- **4x** timeout +- **3x** timeout +- **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ - **1x** undefined symbol: fat\ - **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat - **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio @@ -17,25 +18,25 @@ fail=11 timeout=4 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!\\\"\ | 6277 | -| big.lua | timeout | per-test timeout | 8005 | -| calls.lua | fail | undefined symbol: fat\ | 5170 | +| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6342 | +| big.lua | timeout | per-test timeout | 8008 | +| calls.lua | fail | undefined symbol: fat\ | 5134 | | checktable.lua | skip | internal debug helpers | 0 | -| closure.lua | timeout | per-test timeout | 8004 | +| closure.lua | timeout | per-test timeout | 8007 | | code.lua | skip | bytecode inspection via debug library | 0 | -| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 7085 | +| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 7182 | | db.lua | skip | debug library | 0 | -| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3327 | -| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7865 | +| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3464 | +| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7726 | | files.lua | skip | io library | 0 | | gc.lua | skip | collectgarbage / finalisers | 0 | -| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2110 | -| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1869 | +| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1940 | +| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1759 | | main.lua | skip | standalone interpreter driver | 0 | -| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4658 | -| nextvar.lua | timeout | per-test timeout | 8007 | -| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7287 | +| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4487 | +| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7441 | +| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6440 | | sort.lua | timeout | per-test timeout | 8007 | -| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4566 | -| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2698 | -| verybig.lua | pass | - | 666 | +| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4243 | +| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2425 | +| verybig.lua | pass | - | 622 | diff --git a/plans/lua-on-sx.md b/plans/lua-on-sx.md index 5f40fe78..2e44334c 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 — `package.cpath`/`config`/`loaders`/`searchers`/`searchpath` stubs. attrib.lua moves from #9 (checking `package.cpath` is a string) to "module 'C' not found" — test requires filesystem-based module loading, not tractable. Most remaining failures need Lua pattern matching (pm.lua/strings.lua), env tracking (locals.lua/events.lua), or filesystem (attrib.lua). - 2026-04-24: lua: scoreboard iteration — **parenthesized expressions truncate multi-return** (Lua spec: `(f())` forces single value even if `f` returns multi). Parser wraps `(expr)` in a new `lua-paren` AST node; transpile emits `(lua-first inner)`. Fixes `constructs.lua`@30 (`a,b,c = (f())` expects `a=1, b=nil, c=nil`) and `math.lua`@13. 375/375 green (+2 paren tests). Scoreboard: 8× asserts (was 10). - 2026-04-24: lua: scoreboard iteration — stripped `(else (raise e))` from `lua-tx-loop-guard`. SX `guard` with `(else (raise e))` hangs in a loop (re-enters the same guard). Since unmatched sentinels fall through to the enclosing guard naturally, the else is unnecessary. Diagnosed `calls.lua` undefined-`fat`: `function fat(x)` defined at Lua top-level is scoped inside the SX top-level guard's scope; loadstring-captured closures don't see it via lexical env. Fix would require either dropping the top-level guard (breaking top-level `return`) or dynamic env access — deferred. - 2026-04-24: lua: scoreboard iteration — **method-call double-evaluation bug**. `lua-tx-method-call` emitted `(lua-call (lua-get OBJ name) OBJ args…)` which evaluated OBJ TWICE, so `a:add(10):add(20):add(30).x` computed `110` instead of `60` (side effects applied twice). Fixed by `(let ((__obj OBJ)) (lua-call (lua-get __obj name) __obj args…))`. 373/373 green (+1 chaining test).