lua: parenthesized expressions truncate multi-return via new lua-paren AST node +2 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 22:48:33 +00:00
parent d8be6b8230
commit fb18629916
6 changed files with 61 additions and 44 deletions

View File

@@ -958,6 +958,12 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 1870)
(eval "(lua-eval-ast \"local a = {x=0} function a:add(x) self.x = self.x+x return self end return a:add(10):add(20):add(30).x\")")
;; ── Parenthesized expression truncates multi-return ──────────
(epoch 1880)
(eval "(lua-eval-ast \"local function f() return 1, 2, 3 end local a, b, c = (f()) return (a == 1 and b == nil and c == nil) and 1 or 0\")")
(epoch 1881)
(eval "(lua-eval-ast \"local function f() return 10, 20 end return (f()) + 1\")")
EPOCHS
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1077,7 +1083,7 @@ check 213 "parse and/or prec" '(lua-binop "or" (lua-binop "and"'
check 214 "parse ==" '(lua-binop "==" (lua-name "a") (lua-name "b"))'
check 215 "parse .. right-assoc" '(lua-binop ".." (lua-name "a") (lua-binop ".."'
check 216 "parse ^ right-assoc" '(lua-binop "^" (lua-name "a") (lua-binop "^"'
check 217 "parse paren override" '(lua-binop "*" (lua-binop "+"'
check 217 "parse paren override" '(lua-binop "*" (lua-paren (lua-binop "+"'
check 220 "parse -x" '(lua-unop "-" (lua-name "x"))'
check 221 "parse not x" '(lua-unop "not" (lua-name "x"))'
@@ -1450,6 +1456,10 @@ check 1863 "break in repeat" '3'
# ── Method-call chaining ─────────────────────────────────────
check 1870 "a:add():add():add().x chain" '60'
# ── Parenthesized truncates multi-return ─────────────────────
check 1880 "(f()) scalar coerce" '1'
check 1881 "(f()) + 1 scalar" '11'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"