lua: if/else/elseif body scoping via (let () …); else-branch leak fixed +3 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 20:26:20 +00:00
parent 54d7fcf436
commit f0a4dfbea8
5 changed files with 52 additions and 33 deletions

View File

@@ -908,6 +908,14 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 1801)
(eval "(lua-eval-ast \"do local i = 10 do local i = 100 assert(i == 100) end assert(i == 10) end return \\\"ok\\\"\")")
;; ── if/else/elseif body scoping ──────────────────────────────
(epoch 1810)
(eval "(lua-eval-ast \"local x = 10 if true then local x = 99 end return x\")")
(epoch 1811)
(eval "(lua-eval-ast \"local x = 10 if false then else local x = 99 end return x\")")
(epoch 1812)
(eval "(lua-eval-ast \"local x = 10 if false then elseif true then local x = 99 end return x\")")
EPOCHS
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1368,6 +1376,11 @@ check 1705 "f(a, b, ...) mixed" '783'
check 1800 "inner do local shadows" '10'
check 1801 "nested do scopes" '"ok"'
# ── if/else/elseif body scoping ──────────────────────────────
check 1810 "if then local shadows" '10'
check 1811 "else local shadows" '10'
check 1812 "elseif local shadows" '10'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"