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

@@ -3611,7 +3611,11 @@
(let
((src (js-iterable-to-list (nth args 0)))
(map-fn
(if (< (len args) 2) nil (nth args 1))))
(if (< (len args) 2) nil (nth args 1)))
(this-arg
(if (or (< (len args) 3) (js-undefined? (nth args 2)) (= (nth args 2) nil))
js-global-this
(nth args 2))))
(if
(= map-fn nil)
(let
@@ -3623,8 +3627,9 @@
(for-each
(fn
(x)
(append! result (map-fn x))
(set! i (+ i 1)))
(begin
(append! result (js-call-with-this this-arg map-fn (list x i)))
(set! i (+ i 1))))
src)
result)))))))