lua: byte-to-char only single chars (fix \0-escape regression breaking string lengths)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 21:29:43 +00:00
parent 9435fab790
commit 9560145228
4 changed files with 33 additions and 37 deletions

View File

@@ -43,19 +43,19 @@
"name": "attrib.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 5583
"ms": 5719
},
{
"name": "big.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8007
"ms": 8006
},
{
"name": "calls.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 4566
"ms": 4548
},
{
"name": "checktable.lua",
@@ -67,7 +67,7 @@
"name": "closure.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8007
"ms": 8003
},
{
"name": "code.lua",
@@ -79,7 +79,7 @@
"name": "constructs.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 4358
"ms": 4153
},
{
"name": "db.lua",
@@ -91,13 +91,13 @@
"name": "errors.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
"ms": 3064
"ms": 2938
},
{
"name": "events.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 6749
"ms": 6598
},
{
"name": "files.lua",
@@ -115,13 +115,13 @@
"name": "literals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 1802
"ms": 1859
},
{
"name": "locals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 1557
"ms": 1687
},
{
"name": "main.lua",
@@ -133,43 +133,43 @@
"name": "math.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 3762
"ms": 3774
},
{
"name": "nextvar.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 6669
"ms": 6637
},
{
"name": "pm.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 5572
"ms": 5886
},
{
"name": "sort.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8008
"ms": 8007
},
{
"name": "strings.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 3730
"ms": 4040
},
{
"name": "vararg.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 2031
"ms": 2064
},
{
"name": "verybig.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 534
"ms": 545
}
]
}

View File

@@ -16,25 +16,25 @@ fail=13 timeout=3 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!\\\"\ | 5583 |
| big.lua | timeout | per-test timeout | 8007 |
| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4566 |
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5719 |
| big.lua | timeout | per-test timeout | 8006 |
| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4548 |
| checktable.lua | skip | internal debug helpers | 0 |
| closure.lua | timeout | per-test timeout | 8007 |
| closure.lua | timeout | per-test timeout | 8003 |
| code.lua | skip | bytecode inspection via debug library | 0 |
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4358 |
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4153 |
| db.lua | skip | debug library | 0 |
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 3064 |
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6749 |
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 2938 |
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6598 |
| files.lua | skip | io library | 0 |
| gc.lua | skip | collectgarbage / finalisers | 0 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1802 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1557 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1859 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1687 |
| main.lua | skip | standalone interpreter driver | 0 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3762 |
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6669 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5572 |
| sort.lua | timeout | per-test timeout | 8008 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3730 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2031 |
| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 534 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3774 |
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6637 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5886 |
| sort.lua | timeout | per-test timeout | 8007 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4040 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2064 |
| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 545 |

View File

@@ -3,13 +3,8 @@
(define lua-byte-to-char
(fn (n)
(cond
((= n 0) "\0")
((= n 7) "\a")
((= n 8) "\b")
((= n 9) "\t")
((= n 10) "\n")
((= n 11) "\v")
((= n 12) "\f")
((= n 13) "\r")
((and (>= n 32) (<= n 126)) (char-at __ascii-tok (- n 32)))
(else "?"))))

View File

@@ -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 — `lua-byte-to-char` regression fix. My previous change returned 2-char strings (`"\a"` etc.) for bytes that SX string literals can't express (0, 7, 8, 11, 12, 1431, 127+), breaking `'a\0a'` length from 3 → 4. Now only 9/10/13 and printable 32-126 produce real bytes; others use a single `"?"` placeholder so `string.len` stays correct. literals.lua back to failing at assert #4 (was regressed to #2).
- 2026-04-24: lua: scoreboard iteration — **decimal string escapes** `\ddd` (1-3 digits). Tokenizer `read-string` previously fell through to literal for digits, so `"\65"` came out as `"65"` not `"A"`. Added `read-decimal-escape!` consuming up to 3 digits while keeping value ≤255, plus `\a`/`\b`/`\f`/`\v` control escapes and `lua-byte-to-char` ASCII lookup. 362 tests (+2 escape tests).
- 2026-04-24: lua: scoreboard iteration — **`loadstring` error propagation**. When `loadstring(s)()` was implemented as `eval-expr ( (let () compiled))`, SX's `eval-expr` wrapped any propagated `raise` as "Unhandled exception: X" — so `error('hi')` inside a loadstring'd chunk came out as that wrapped string instead of the clean `"hi"` Lua expects. Fix: transpile source once into a lambda AST, `eval-expr` it ONCE to get a callable fn value, return that — subsequent calls propagate raises cleanly. Guarded parse-failure path returns `(nil, err)` per Lua convention. vararg.lua now runs past assert #18; errors.lua past parse stage.
- 2026-04-24: lua: scoreboard iteration — `table.sort` O(n²) insertion-sort → **quicksort** (Lomuto partition). 1000-element sorts finish in ms; but `sort.lua` uses 30k elements and still times out even at 90s (metamethod-heavy interpreter overhead). Correctness verified on 1000/5000 element random arrays.