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

@@ -303,13 +303,18 @@
rhs))
(else (error "lua-transpile: bad assignment target")))))
(define
lua-tx-if-body
(fn (body)
(list (make-symbol "let") (list) body)))
(define
lua-tx-if
(fn
(node)
(let
((cnd (lua-tx (nth node 1)))
(then-body (lua-tx (nth node 2)))
(then-body (lua-tx-if-body (lua-tx (nth node 2))))
(elseifs (nth node 3))
(else-body (nth node 4)))
(if
@@ -333,7 +338,7 @@
clauses
(append
clauses
(list (list (make-symbol "else") (lua-tx else-body)))))))))
(list (list (make-symbol "else") (lua-tx-if-body (lua-tx else-body))))))))))
(define
lua-tx-elseif
@@ -341,7 +346,7 @@
(pair)
(list
(list (make-symbol "lua-truthy?") (lua-tx (first pair)))
(lua-tx (nth pair 1)))))
(lua-tx-if-body (lua-tx (nth pair 1))))))
(define
lua-tx-while