js-on-sx: obj destructure rename + rest + nested tolerance

Pattern {key: local-name} emits ("rename" key local). Transpile
emits (define local (js-get-prop tmp key)).

Rest in obj pattern stubs (no supported), nested {} and [] treated
as holes.

442/444 unit (+2), 148/148 slice unchanged.
This commit is contained in:
2026-04-23 23:19:31 +00:00
parent c5e2bc2fe1
commit 9f9e4e1e9d
3 changed files with 53 additions and 4 deletions

View File

@@ -935,6 +935,17 @@
(names tmp-sym tail)
(cond
((empty? names) tail)
((= (first names) nil)
(js-vardecl-obj-forms (rest names) tmp-sym tail))
((and (list? (first names)) (= (first (first names)) "rename"))
(cons
(list
(js-sym "define")
(js-sym (nth (first names) 2))
(list (js-sym "js-get-prop") tmp-sym (nth (first names) 1)))
(js-vardecl-obj-forms (rest names) tmp-sym tail)))
((and (list? (first names)) (= (first (first names)) "rest"))
(js-vardecl-obj-forms (rest names) tmp-sym tail))
(else
(cons
(list