From bfec2a43206a1ddae8fd978106e34abfefdc8de0 Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 8 May 2026 06:36:54 +0000 Subject: [PATCH] js-on-sx: JS functions accept extra args silently SX strictly arity-checks lambdas; JS allows passing more args than declared (extras accessible via arguments). Was raising "f expects 1 args, got 2" whenever Array.from passed (value, index) to a 1-arg mapFn. Fixed in js-build-param-list: every JS param list now ends with &rest __extra_args__ unless an explicit rest is present, so extras are silently absorbed. conformance.sh: 148/148. --- lib/js/test262-scoreboard.json | 2 +- lib/js/test262-scoreboard.md | 2 +- lib/js/transpile.sx | 2 +- plans/js-on-sx.md | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/js/test262-scoreboard.json b/lib/js/test262-scoreboard.json index 6d8c96fd..d3778c02 100644 --- a/lib/js/test262-scoreboard.json +++ b/lib/js/test262-scoreboard.json @@ -56,6 +56,6 @@ ] ], "pinned_commit": "d5e73fc8d2c663554fb72e2380a8c2bc1a318a33", - "elapsed_seconds": 146.9, + "elapsed_seconds": 154.6, "workers": 1 } \ No newline at end of file diff --git a/lib/js/test262-scoreboard.md b/lib/js/test262-scoreboard.md index d60ae7b3..d72acb66 100644 --- a/lib/js/test262-scoreboard.md +++ b/lib/js/test262-scoreboard.md @@ -1,7 +1,7 @@ # test262 scoreboard Pinned commit: `d5e73fc8d2c663554fb72e2380a8c2bc1a318a33` -Wall time: 146.9s +Wall time: 154.6s **Total:** 80/99 runnable passed (80.8%). Raw: pass=80 fail=13 skip=1 timeout=6 total=100. diff --git a/lib/js/transpile.sx b/lib/js/transpile.sx index 5b219e59..c044f558 100644 --- a/lib/js/transpile.sx +++ b/lib/js/transpile.sx @@ -930,7 +930,7 @@ (fn (params) (cond - ((empty? params) (list)) + ((empty? params) (list (js-sym "&rest") (js-sym "__extra_args__"))) ((and (list? (first params)) (js-tag? (first params) "js-rest")) (list (js-sym "&rest") (js-sym (nth (first params) 1)))) (else diff --git a/plans/js-on-sx.md b/plans/js-on-sx.md index 2383f955..721fd756 100644 --- a/plans/js-on-sx.md +++ b/plans/js-on-sx.md @@ -158,6 +158,8 @@ Each item: implement → tests → update progress. Mark `[x]` when tests green. Append-only record of completed iterations. Loop writes one line per iteration: date, what was done, test count delta. +- 2026-05-08 — **JS functions accept extra args silently (per spec).** SX strictly arity-checks: `(fn (a) ...)` rejects 2 args, but JS allows passing more args than declared (the extras are accessible via `arguments`). Was raising `f expects 1 args, got 2` whenever Array.from passed `(value, index)` to a 1-arg mapFn, etc. Fixed in `js-build-param-list` (transpile.sx): every JS function param list now ends with `&rest __extra_args__` (unless an explicit rest param is already present), so extras are silently absorbed. Headline scoreboards unchanged but unblocks a class of harness-mediated failures. conformance.sh: 148/148. + - 2026-05-08 — **Lowered array padding bail-out from 2^32-1 to 1M.** Yesterday's 2^32-1 threshold still allowed indices like `2147483648` to pad billions of `js-undefined` entries, hanging the worker. Without sparse-array support there's no semantic value in supporting >1M sparse padding; lowering the bail to 1M turns those tests into fast assertion failures instead of timeouts. Removes another timeout (Array 7→1). built-ins/Array stays at 23/45, but the run is faster and no longer wall-time-bound. conformance.sh: 148/148. - 2026-05-08 — **Out-of-range array indices and lengths no longer hang.** `arr[4294967295] = 'x'` and `arr.length = 4294967295` were padding the SX list with `js-undefined` for ~4 billion entries — guaranteed timeout. Per ES spec, indices ≥ 2^32-1 aren't array indices (they're regular properties, which we can't store on a list). Added a `(>= i 4294967295)` bail-out clause to both `js-list-set!` (numeric index path) and the `length` setter; both now no-op at that bound. Removed 5 of the 7 Array timeouts. built-ins/Array: 21/45 → 23/45. conformance.sh: 148/148.