Commit graph

1 commit

Author SHA1 Message Date
kommander
493240ee71 fix(codemode): match the reference's Array methods on frozen arrays, callbacks and iteration
Mutating Array methods run the reference's check of what their first write
would hit: adding to a non-extensible array, deleting from a sealed one, or
writing a frozen one each fail with the reference's message, sealed arrays
no longer pop or shift, and reverse leaves a frozen array of fewer than two
items alone. sort checks its comparator first and leaves the array as it
was when the comparator throws; it used to empty it.

Callback methods of Array, Map, Set and Uint8Array.sort name themselves in
the reference's 'Array.map expects a function callback.' forEach, map,
filter, some, every, flatMap and reduceRight skip indexes a callback cut
off by shrinking the array, and includes and indexOf on an empty array
return before converting fromIndex.

Array.from checks its mapper first, maps an iterable as it reads it and
closes the iterator when the mapper throws (an endless iterator ran out of
memory), and rejects primitives and promises. Object.fromEntries reads its
entries one at a time, closes the iterator on a bad entry, and accepts only
entries without opaque references, like the reference. Array.prototype is
an array, and an arguments object is never frozen merely by being
non-extensible.

On top of the array holes: mutating methods check mutability once (push
returns at once for an array with no such flags), and an index read past an
array's end or at a hole finds Array.prototype's own items, which store an
index without interning it. Touches ops.rs (inherited_elem).
2026-11-18 18:56:11 +01:00