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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user