js-on-sx: arguments object + Array.from mapFn calling convention
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 45s

Three related fixes:
1. Every JS function body binds arguments to (cons p1 ... __extra_args__),
   so arguments[k] and arguments.length work as expected.
2. Array.from(iter, mapFn) invokes mapFn through js-call-with-this
   with the index as second arg (was (map-fn x), missing index and
   inheriting outer this).
3. thisArg defaults to js-global-this when omitted (per non-strict ES).
conformance.sh: 148/148.
This commit is contained in:
2026-05-08 15:31:33 +00:00
parent 47e68454ad
commit f0dffd275d
3 changed files with 28 additions and 4 deletions

View File

@@ -940,6 +940,21 @@
(js-param-sym (first params))
(js-build-param-list (rest params)))))))
(define
js-arguments-build-form
(fn
(params)
(cond
((empty? params)
(js-sym "__extra_args__"))
((and (list? (first params)) (js-tag? (first params) "js-rest"))
(js-sym (nth (first params) 1)))
(else
(list
(js-sym "cons")
(js-param-sym (first params))
(js-arguments-build-form (rest params)))))))
(define
js-param-init-forms
(fn
@@ -1402,7 +1417,9 @@
param-syms
(list
(js-sym "let")
(list (list (js-sym "this") (list (js-sym "js-this"))))
(list
(list (js-sym "this") (list (js-sym "js-this")))
(list (js-sym "arguments") (js-arguments-build-form params)))
(list
(js-sym "let")
(list