lua: Lua 5.0-style arg auto-binding in vararg functions; assert-counter diagnostic +2 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:
@@ -1591,3 +1591,21 @@
|
||||
|
||||
;; T — debug/testC placeholder for tests that check it conditionally
|
||||
(define T nil)
|
||||
|
||||
;; Build Lua 5.0-style `arg` table: array + .n counter, skipping leading explicit params.
|
||||
(define
|
||||
lua-varargs-arg-table
|
||||
(fn (args skip)
|
||||
(let ((t {}) (n 0))
|
||||
(begin
|
||||
(define
|
||||
va-build
|
||||
(fn (i)
|
||||
(when (< i (len args))
|
||||
(begin
|
||||
(set! n (+ n 1))
|
||||
(dict-set! t (str n) (nth args i))
|
||||
(va-build (+ i 1))))))
|
||||
(va-build skip)
|
||||
(dict-set! t "n" n)
|
||||
t))))
|
||||
|
||||
Reference in New Issue
Block a user