js-on-sx: arr.length = N extends the array
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 41s

js-list-set! was a no-op for the length key. Added a clause that
pads with js-undefined via js-pad-list! when target > current.
Truncation skipped: the pop-last! SX primitive doesn't actually
mutate the list (length unchanged after the call), so no clean
way to shrink in place from SX. Extension covers common cases.
built-ins/Array: 16/45 → 17/45. conformance.sh: 148/148.
This commit is contained in:
2026-05-08 01:38:51 +00:00
parent b9dc69a3c1
commit 24a67fae97
4 changed files with 64 additions and 26 deletions

View File

@@ -2800,7 +2800,13 @@
(else (do (js-pad-list! lst n i) (append! lst val))))))
((and (= (type-of key) "string") (js-is-numeric-string? key))
(js-list-set! lst (js-string-to-number key) val))
((= key "length") nil)
((= key "length")
(let
((target (js-num-to-int (js-to-number val))) (n (len lst)))
(cond
((< target 0) nil)
((> target n) (js-pad-list! lst n target))
(else nil))))
(else nil))))
(define
js-pad-list!