lua: decimal string escapes \\ddd + control escapes (\\a/\\b/\\f/\\v) +2 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -43,19 +43,19 @@
|
||||
"name": "attrib.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 5841
|
||||
"ms": 5583
|
||||
},
|
||||
{
|
||||
"name": "big.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8008
|
||||
"ms": 8007
|
||||
},
|
||||
{
|
||||
"name": "calls.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 4666
|
||||
"ms": 4566
|
||||
},
|
||||
{
|
||||
"name": "checktable.lua",
|
||||
@@ -67,7 +67,7 @@
|
||||
"name": "closure.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8008
|
||||
"ms": 8007
|
||||
},
|
||||
{
|
||||
"name": "code.lua",
|
||||
@@ -79,7 +79,7 @@
|
||||
"name": "constructs.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 4155
|
||||
"ms": 4358
|
||||
},
|
||||
{
|
||||
"name": "db.lua",
|
||||
@@ -91,13 +91,13 @@
|
||||
"name": "errors.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
|
||||
"ms": 3155
|
||||
"ms": 3064
|
||||
},
|
||||
{
|
||||
"name": "events.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 6725
|
||||
"ms": 6749
|
||||
},
|
||||
{
|
||||
"name": "files.lua",
|
||||
@@ -115,13 +115,13 @@
|
||||
"name": "literals.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 1787
|
||||
"ms": 1802
|
||||
},
|
||||
{
|
||||
"name": "locals.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||
"ms": 1539
|
||||
"ms": 1557
|
||||
},
|
||||
{
|
||||
"name": "main.lua",
|
||||
@@ -133,43 +133,43 @@
|
||||
"name": "math.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 3892
|
||||
"ms": 3762
|
||||
},
|
||||
{
|
||||
"name": "nextvar.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 6711
|
||||
"ms": 6669
|
||||
},
|
||||
{
|
||||
"name": "pm.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 5734
|
||||
"ms": 5572
|
||||
},
|
||||
{
|
||||
"name": "sort.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8007
|
||||
"ms": 8008
|
||||
},
|
||||
{
|
||||
"name": "strings.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 3937
|
||||
"ms": 3730
|
||||
},
|
||||
{
|
||||
"name": "vararg.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 2096
|
||||
"ms": 2031
|
||||
},
|
||||
{
|
||||
"name": "verybig.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||
"ms": 533
|
||||
"ms": 534
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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!\\\"\ | 5841 |
|
||||
| big.lua | timeout | per-test timeout | 8008 |
|
||||
| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4666 |
|
||||
| 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 |
|
||||
| checktable.lua | skip | internal debug helpers | 0 |
|
||||
| closure.lua | timeout | per-test timeout | 8008 |
|
||||
| closure.lua | timeout | per-test timeout | 8007 |
|
||||
| code.lua | skip | bytecode inspection via debug library | 0 |
|
||||
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4155 |
|
||||
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4358 |
|
||||
| db.lua | skip | debug library | 0 |
|
||||
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 3155 |
|
||||
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6725 |
|
||||
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 3064 |
|
||||
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6749 |
|
||||
| files.lua | skip | io library | 0 |
|
||||
| gc.lua | skip | collectgarbage / finalisers | 0 |
|
||||
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1787 |
|
||||
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1539 |
|
||||
| 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 |
|
||||
| main.lua | skip | standalone interpreter driver | 0 |
|
||||
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3892 |
|
||||
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6711 |
|
||||
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5734 |
|
||||
| sort.lua | timeout | per-test timeout | 8007 |
|
||||
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3937 |
|
||||
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2096 |
|
||||
| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 533 |
|
||||
| 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 |
|
||||
|
||||
@@ -922,6 +922,12 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1821)
|
||||
(eval "(lua-eval-ast \"function f(a, ...) return arg[1] + arg[2] + arg[3] end return f({}, 10, 20, 30)\")")
|
||||
|
||||
;; ── Decimal-escape strings ────────────────────────────────────
|
||||
(epoch 1830)
|
||||
(eval "(lua-eval-ast \"return \\\"\\\\65\\\"\")")
|
||||
(epoch 1831)
|
||||
(eval "(lua-eval-ast \"if \\\"\\\\09912\\\" == \\\"c12\\\" then return 1 else return 0 end\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1391,6 +1397,10 @@ check 1812 "elseif local shadows" '10'
|
||||
check 1820 "arg.n in vararg fn" '3'
|
||||
check 1821 "arg[i] access" '60'
|
||||
|
||||
# ── Decimal-escape strings ───────────────────────────────────
|
||||
check 1830 "\\65 → A" '"A"'
|
||||
check 1831 "\\099 + 12 → c12" '1'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
(define __ascii-tok " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")
|
||||
|
||||
(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 "?"))))
|
||||
|
||||
(define lua-make-token (fn (type value pos) {:pos pos :value value :type type}))
|
||||
|
||||
(define lua-digit? (fn (c) (and (not (= c nil)) (>= c "0") (<= c "9"))))
|
||||
@@ -228,6 +244,35 @@
|
||||
(begin (advance! 1) (read-decimal-digits!)))
|
||||
(read-exp-part!)
|
||||
(parse-number (slice src start pos)))))))
|
||||
(define
|
||||
lua-char-one-tok
|
||||
(fn (n)
|
||||
(cond
|
||||
((= n 7) (str (list n)))
|
||||
((= n 8) (str (list n)))
|
||||
((= n 11) (str (list n)))
|
||||
((= n 12) (str (list n)))
|
||||
(else (str (list n))))))
|
||||
(define
|
||||
read-decimal-escape!
|
||||
(fn (chars)
|
||||
(let ((d0 (cur)))
|
||||
(begin
|
||||
(advance! 1)
|
||||
(let ((n (- (char-code d0) (char-code "0"))))
|
||||
(begin
|
||||
(when
|
||||
(and (< pos src-len) (lua-digit? (cur)))
|
||||
(begin
|
||||
(set! n (+ (* n 10) (- (char-code (cur)) (char-code "0"))))
|
||||
(advance! 1)
|
||||
(when
|
||||
(and (< pos src-len) (lua-digit? (cur))
|
||||
(<= (+ (* n 10) (- (char-code (cur)) (char-code "0"))) 255))
|
||||
(begin
|
||||
(set! n (+ (* n 10) (- (char-code (cur)) (char-code "0"))))
|
||||
(advance! 1)))))
|
||||
(append! chars (lua-byte-to-char n))))))))
|
||||
(define
|
||||
read-string
|
||||
(fn
|
||||
@@ -251,14 +296,18 @@
|
||||
((ch (cur)))
|
||||
(begin
|
||||
(cond
|
||||
((= ch "n") (append! chars "\n"))
|
||||
((= ch "t") (append! chars "\t"))
|
||||
((= ch "r") (append! chars "\r"))
|
||||
((= ch "\\") (append! chars "\\"))
|
||||
((= ch "'") (append! chars "'"))
|
||||
((= ch "\"") (append! chars "\""))
|
||||
(else (append! chars ch)))
|
||||
(advance! 1))))
|
||||
((= ch "n") (begin (append! chars "\n") (advance! 1)))
|
||||
((= ch "t") (begin (append! chars "\t") (advance! 1)))
|
||||
((= ch "r") (begin (append! chars "\r") (advance! 1)))
|
||||
((= ch "a") (begin (append! chars (lua-char-one-tok 7)) (advance! 1)))
|
||||
((= ch "b") (begin (append! chars (lua-char-one-tok 8)) (advance! 1)))
|
||||
((= ch "f") (begin (append! chars (lua-char-one-tok 12)) (advance! 1)))
|
||||
((= ch "v") (begin (append! chars (lua-char-one-tok 11)) (advance! 1)))
|
||||
((= ch "\\") (begin (append! chars "\\") (advance! 1)))
|
||||
((= ch "'") (begin (append! chars "'") (advance! 1)))
|
||||
((= ch "\"") (begin (append! chars "\"") (advance! 1)))
|
||||
((lua-digit? ch) (read-decimal-escape! chars))
|
||||
(else (begin (append! chars ch) (advance! 1)))))))
|
||||
(loop)))
|
||||
((= (cur) quote-char) (advance! 1))
|
||||
(else
|
||||
|
||||
@@ -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 — **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.
|
||||
- 2026-04-24: lua: scoreboard iteration — `dostring(s)` alias for `loadstring(s)()` (Lua 5.0 compat used by literals.lua). Diagnosed `locals.lua` call-non-fn at call #18 → `getfenv/setfenv` stub-return pattern fails `assert(getfenv(foo("")) == a)` (need real env tracking, deferred). Tokenizer long-string-leading-NL rule verified correct.
|
||||
|
||||
Reference in New Issue
Block a user