mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
The reference keeps an array's elements in a host JavaScript array, which
JavaScriptCore stores sparsely, so a[4294967294] = x works and makes the
length 4294967295. Here a write that far failed with 'Invalid array length'.
An array now turns sparse when a write lands past the longest dense array
(MAX_ARRAY_LEN): its items keep the dense prefix, the SPARSE object flag is
set, and its other elements and its length are its own properties, so
snapshots and reachability carry them unchanged. Element reads and writes,
in, hasOwnProperty, delete, keys, for-in, length (which makes it dense again
once short enough), push, pop, at, slice, includes, indexOf and lastIndexOf
work on it as in the reference, and the callback methods, reduce, flat and
flatMap visit only the elements it holds. Code that walks every element
makes the array dense first and fails with the reference's errors when it
is too long ('Invalid array length', 'Out of memory' for sort), where the
reference either fails or runs on for minutes. Logs show its first
elements. Arrays at most MAX_ARRAY_LEN long, every one the benchmarks make
among them, stay dense and take the same paths as before.
Setting length out of range and spreading too many values now say
'Invalid array length' without a period, as the reference does. Touches
object.rs (SPARSE), ops.rs (element and length paths, define, iteration),
convert.rs, host.rs, web.rs (structured clone), object.rs, buffer.rs.
The last nine test262 files leave rust-skipped.txt, which is now empty.
|
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
| reference-gaps.txt | ||
| reference.ts | ||
| run.sh | ||
| rust-skipped.txt | ||
test262 parity
Runs the reference's pinned test262 file set (../codemode/test/test262) with the reference's semantics and
checks the failures against rust-skipped.txt.
bash test262/run.sh # what CI runs
bash test262/run.sh built-ins/Array # one directory, by path prefix
bash test262/run.sh --write # regenerate both gap lists from the current outcomes
run.shclones tc39/test262 at the reference manifest's revision into a cache directory (TEST262_CHECKOUT), then runs the reference's ownscript/sync-test262.tsintotarget/test262(TEST262_FILES). The file set and its filters are the reference's, unchanged.src/main.rsruns each file like the reference'srun.ts:"use strict"and the one-lineassertprelude prepended on the same line, the host harness ($assertchecks,Test262Error,compareArray,$DONE,$DONOTEVALUATE) from the crate'stest262feature, a 5 s timeout, negative tests judged by phase, and async tests drained and judged by$DONE.- Parity runs both ways, with one list per direction. Both may only shrink.
rust-skipped.txtlists the files that fail here but pass in the reference, each with a reason category. CI fails when an unlisted file fails, and when a listed file passes.reference-gaps.txtlists the files in the reference'sskipped.txtthat pass here: gaps on the TypeScript side. Each category starts withreal(Rust has the behaviour, TypeScript lacks it) oraccident(Rust passes through a looser check where the reference is deliberately strict; Rust should match the reference). CI fails when an unlisted file passes, when a listed file fails here or leaves the reference'sskipped.txt, and whenreference.ts, which runs the listed files through the reference's ownrun.ts, sees one pass.
--writeregenerates both lists. It keeps the categories already inreference-gaps.txtand marks new entriesuncategorised, with the reference's reason, for a person to judge.