js-on-sx: rest in array pattern + nested pattern tolerance

Array destructure now supports [a, ...rest]. Rest entry is
transpiled to (define name (js-list-slice tmp i (len tmp))).

Nested patterns like [[a,b], c] now parse (as holes) instead of
erroring. jp-skip-balanced skips nested groups.

440/442 unit (+2), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 22:58:49 +00:00
parent 1459f7a637
commit c257971bb1
3 changed files with 72 additions and 0 deletions

View File

@@ -951,6 +951,17 @@
((empty? names) tail)
((= (first names) nil)
(js-vardecl-arr-forms (rest names) tmp-sym (+ i 1) tail))
((and (list? (first names)) (= (first (first names)) "rest"))
(cons
(list
(js-sym "define")
(js-sym (nth (first names) 1))
(list
(js-sym "js-list-slice")
tmp-sym
i
(list (js-sym "len") tmp-sym)))
tail))
(else
(cons
(list