js-on-sx: js-iterable-to-list respects length on array-like dicts
Array.from({length: 3, 0: 'a', 1: 'b', 2: 'c'}) used to return ['3','a','b','c']
because js-iterable-to-list walked dict keys in insertion order and included
the 'length' key as a value.
Now the dict branch checks for 'length' key first — if present, delegates to
js-arraylike-to-list which reads indices 0..length-1. Otherwise falls back
to value-order for plain objects.
Fixes Array.from, spread (...dict), and destructure from array-likes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2195,10 +2195,14 @@
|
||||
((list? v) v)
|
||||
((= (type-of v) "string") (js-string-to-list v 0 (list)))
|
||||
((dict? v)
|
||||
(let
|
||||
((result (list)))
|
||||
(for-each (fn (k) (append! result (get v k))) (keys v))
|
||||
result))
|
||||
(cond
|
||||
((contains? (keys v) "length") (js-arraylike-to-list v))
|
||||
(else
|
||||
(let
|
||||
((result (list)))
|
||||
(begin
|
||||
(for-each (fn (k) (append! result (get v k))) (keys v))
|
||||
result)))))
|
||||
(else (list)))))
|
||||
|
||||
(define
|
||||
|
||||
Reference in New Issue
Block a user