lua: unary-minus/^ precedence (^ binds tighter); parse-pow-chain helper +3 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:
@@ -211,6 +211,8 @@
|
|||||||
(lua-tok-type t)
|
(lua-tok-type t)
|
||||||
" "
|
" "
|
||||||
(lua-tok-value t))))))))
|
(lua-tok-value t))))))))
|
||||||
|
(define parse-pow-chain
|
||||||
|
(fn () (let ((lhs (parse-primary))) (parse-binop-rhs 10 lhs))))
|
||||||
(set!
|
(set!
|
||||||
parse-unary
|
parse-unary
|
||||||
(fn
|
(fn
|
||||||
@@ -228,7 +230,7 @@
|
|||||||
(begin
|
(begin
|
||||||
(advance-tok!)
|
(advance-tok!)
|
||||||
(list (quote lua-unop) "not" (parse-unary))))
|
(list (quote lua-unop) "not" (parse-unary))))
|
||||||
(else (parse-primary)))))
|
(else (parse-pow-chain)))))
|
||||||
(define
|
(define
|
||||||
parse-binop-rhs
|
parse-binop-rhs
|
||||||
(fn
|
(fn
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"top_failure_modes": [
|
"top_failure_modes": [
|
||||||
[
|
[
|
||||||
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
10
|
9
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"timeout",
|
"timeout",
|
||||||
@@ -21,6 +21,10 @@
|
|||||||
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||||
2
|
2
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
|
||||||
|
1
|
||||||
|
],
|
||||||
[
|
[
|
||||||
"other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
|
"other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
|
||||||
1
|
1
|
||||||
@@ -43,7 +47,7 @@
|
|||||||
"name": "attrib.lua",
|
"name": "attrib.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 5719
|
"ms": 6000
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "big.lua",
|
"name": "big.lua",
|
||||||
@@ -55,7 +59,7 @@
|
|||||||
"name": "calls.lua",
|
"name": "calls.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 4548
|
"ms": 4946
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "checktable.lua",
|
"name": "checktable.lua",
|
||||||
@@ -78,8 +82,8 @@
|
|||||||
{
|
{
|
||||||
"name": "constructs.lua",
|
"name": "constructs.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
|
||||||
"ms": 4153
|
"ms": 4533
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "db.lua",
|
"name": "db.lua",
|
||||||
@@ -91,13 +95,13 @@
|
|||||||
"name": "errors.lua",
|
"name": "errors.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
|
"reason": "other: Unhandled exception: \\\"Not callable: nil (kont=10 frames)\\",
|
||||||
"ms": 2938
|
"ms": 3217
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "events.lua",
|
"name": "events.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 6598
|
"ms": 7215
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "files.lua",
|
"name": "files.lua",
|
||||||
@@ -115,13 +119,13 @@
|
|||||||
"name": "literals.lua",
|
"name": "literals.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 1859
|
"ms": 1901
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "locals.lua",
|
"name": "locals.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||||
"ms": 1687
|
"ms": 1693
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "main.lua",
|
"name": "main.lua",
|
||||||
@@ -133,19 +137,19 @@
|
|||||||
"name": "math.lua",
|
"name": "math.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 3774
|
"ms": 4095
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nextvar.lua",
|
"name": "nextvar.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 6637
|
"ms": 7177
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pm.lua",
|
"name": "pm.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 5886
|
"ms": 6048
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sort.lua",
|
"name": "sort.lua",
|
||||||
@@ -157,19 +161,19 @@
|
|||||||
"name": "strings.lua",
|
"name": "strings.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 4040
|
"ms": 3990
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "vararg.lua",
|
"name": "vararg.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||||
"ms": 2064
|
"ms": 2249
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "verybig.lua",
|
"name": "verybig.lua",
|
||||||
"status": "fail",
|
"status": "fail",
|
||||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||||
"ms": 545
|
"ms": 572
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,10 @@ fail=13 timeout=3 skip=8 total=24
|
|||||||
|
|
||||||
## Top failure modes
|
## Top failure modes
|
||||||
|
|
||||||
- **10x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\
|
- **9x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\
|
||||||
- **3x** timeout
|
- **3x** timeout
|
||||||
- **2x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio
|
- **2x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio
|
||||||
|
- **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat
|
||||||
- **1x** other: Unhandled exception: \"Not callable: nil (kont=10 frames)\
|
- **1x** other: Unhandled exception: \"Not callable: nil (kont=10 frames)\
|
||||||
|
|
||||||
## Per-test results
|
## Per-test results
|
||||||
@@ -16,25 +17,25 @@ fail=13 timeout=3 skip=8 total=24
|
|||||||
|---|---|---|---:|
|
|---|---|---|---:|
|
||||||
| all.lua | skip | driver uses dofile to chain other tests | 0 |
|
| all.lua | skip | driver uses dofile to chain other tests | 0 |
|
||||||
| api.lua | skip | requires testC (C debug library) | 0 |
|
| api.lua | skip | requires testC (C debug library) | 0 |
|
||||||
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5719 |
|
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6000 |
|
||||||
| big.lua | timeout | per-test timeout | 8006 |
|
| big.lua | timeout | per-test timeout | 8006 |
|
||||||
| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4548 |
|
| calls.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4946 |
|
||||||
| checktable.lua | skip | internal debug helpers | 0 |
|
| checktable.lua | skip | internal debug helpers | 0 |
|
||||||
| closure.lua | timeout | per-test timeout | 8003 |
|
| closure.lua | timeout | per-test timeout | 8003 |
|
||||||
| code.lua | skip | bytecode inspection via debug library | 0 |
|
| code.lua | skip | bytecode inspection via debug library | 0 |
|
||||||
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4153 |
|
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 4533 |
|
||||||
| db.lua | skip | debug library | 0 |
|
| db.lua | skip | debug library | 0 |
|
||||||
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 2938 |
|
| errors.lua | fail | other: Unhandled exception: \"Not callable: nil (kont=10 frames)\ | 3217 |
|
||||||
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6598 |
|
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7215 |
|
||||||
| files.lua | skip | io library | 0 |
|
| files.lua | skip | io library | 0 |
|
||||||
| gc.lua | skip | collectgarbage / finalisers | 0 |
|
| gc.lua | skip | collectgarbage / finalisers | 0 |
|
||||||
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1859 |
|
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1901 |
|
||||||
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1687 |
|
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1693 |
|
||||||
| main.lua | skip | standalone interpreter driver | 0 |
|
| main.lua | skip | standalone interpreter driver | 0 |
|
||||||
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3774 |
|
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4095 |
|
||||||
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6637 |
|
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7177 |
|
||||||
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5886 |
|
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6048 |
|
||||||
| sort.lua | timeout | per-test timeout | 8007 |
|
| sort.lua | timeout | per-test timeout | 8007 |
|
||||||
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4040 |
|
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3990 |
|
||||||
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2064 |
|
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2249 |
|
||||||
| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 545 |
|
| verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 572 |
|
||||||
|
|||||||
@@ -928,6 +928,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
|||||||
(epoch 1831)
|
(epoch 1831)
|
||||||
(eval "(lua-eval-ast \"if \\\"\\\\09912\\\" == \\\"c12\\\" then return 1 else return 0 end\")")
|
(eval "(lua-eval-ast \"if \\\"\\\\09912\\\" == \\\"c12\\\" then return 1 else return 0 end\")")
|
||||||
|
|
||||||
|
;; ── Unary-minus / ^ precedence (Lua spec: ^ tighter than -) ──
|
||||||
|
(epoch 1840)
|
||||||
|
(eval "(lua-eval-ast \"return -2^2\")")
|
||||||
|
(epoch 1841)
|
||||||
|
(eval "(lua-eval-ast \"return 2^3^2\")")
|
||||||
|
(epoch 1842)
|
||||||
|
(eval "(lua-eval-ast \"if -2^2 == -4 then return 1 else return 0 end\")")
|
||||||
|
|
||||||
EPOCHS
|
EPOCHS
|
||||||
|
|
||||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||||
@@ -1401,6 +1409,11 @@ check 1821 "arg[i] access" '60'
|
|||||||
check 1830 "\\65 → A" '"A"'
|
check 1830 "\\65 → A" '"A"'
|
||||||
check 1831 "\\099 + 12 → c12" '1'
|
check 1831 "\\099 + 12 → c12" '1'
|
||||||
|
|
||||||
|
# ── Unary-minus / ^ precedence (Lua: ^ tighter than unary -) ──
|
||||||
|
check 1840 "-2^2 = -4" '-4'
|
||||||
|
check 1841 "2^3^2 = 512 (right-assoc)" '512'
|
||||||
|
check 1842 "-2^2 == -4 true" '1'
|
||||||
|
|
||||||
TOTAL=$((PASS + FAIL))
|
TOTAL=$((PASS + FAIL))
|
||||||
if [ $FAIL -eq 0 ]; then
|
if [ $FAIL -eq 0 ]; then
|
||||||
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ Each item: implement → tests → tick box → update progress log.
|
|||||||
|
|
||||||
_Newest first. Agent appends on every commit._
|
_Newest first. Agent appends on every commit._
|
||||||
|
|
||||||
|
- 2026-04-24: lua: scoreboard iteration — **unary-minus / `^` precedence fix**. Per Lua spec, `^` binds tighter than unary `-`, so `-2^2` should parse as `-(2^2) = -4`, not `(-2)^2 = 4`. My parser recursed into `parse-unary` and then let `^` bind to the already-negated operand. Added `parse-pow-chain` helper and changed the `else` branch of `parse-unary` to parse a primary + `^`-chain before returning; unary operators now wrap the full `^`-chain. Fixed `constructs.lua` past assert #3 (moved to compare-incompatible). 365/365 green (+3 precedence tests).
|
||||||
- 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, 14–31, 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 — `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, 14–31, 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 — **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 — **`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.
|
||||||
|
|||||||
Reference in New Issue
Block a user