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
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user