Skip to content

runtime/array: fix Array instance prototype, length, and indexed-property semantics #3985

Description

@andrewtdiz

Summary

Current Test262 (c262) launch triage still shows arrays failing on core runtime semantics: Array() / new Array() / array literals do not consistently behave like real Array exotic objects. This shows up as wrong length, missing indexed own properties, missing Array.prototype behavior, and incorrect prototype/class checks.

Evidence

Run from origin/main at 1f6d20e19 on 2026-06-01, Node v25.9.0, Test262 4249661388e5d3f92a85186213da140a6481490f:

scripts/test262_subset.py --root /tmp/perry-test262-4249661 --dir built-ins/Array --max 180 --timeout 10 --sample-cap 50 --report /tmp/perry-c262-builtins-array.json
scripts/test262_subset.py --root /tmp/perry-test262-4249661 --dir language/expressions --max 250 --timeout 10 --sample-cap 40 --report /tmp/perry-c262-language-expressions.json

Observed:

  • built-ins/Array: 76 pass, 104 runtime-fail, 0 compile-fail, 42.2% sample parity.
  • language/expressions: 195 pass, 51 runtime-fail, 4 compile-fail, 78.0% sample parity; many failures are array-literal/prototype fallout.

Representative failures:

  • built-ins/Array/S15.4.1_A2.1_T1.js: Array(0, 1, 0, 1).length expected 4, Perry reports 0.
  • built-ins/Array/15.4.5.1-5-2.js: a.length expected 3, Perry reports 193.
  • built-ins/Array/S15.4.1_A1.1_T2.js: Array().toString() expected [object Array], Perry reports empty string.
  • language/expressions/array/S11.1.4_A1.1.js: array literal .toString === Array.prototype.toString, Perry reports undefined.
  • built-ins/Array/isArray/15.4.3.2-0-5.js: Array.isArray(Array.prototype) expected true, Perry reports false.

Product triage

User outcome: ordinary package and app code can trust arrays for construction, reflection, serialization, indexed writes, and length-sensitive logic.

Shortest path: fix Array exotic object allocation and update rules first, before widening into every Array prototype method tail.

Manual/narrow assumptions to test: a small c262 slice plus hand probes for Array(), new Array(), literals, holes, 4294967295, non-index properties, hasOwnProperty, toString, and Array.isArray(Array.prototype) should catch the main regression class.

Core vs nice: core is prototype identity, length/index invariants, own indexed property visibility, and array-literal parity. Nice later work is method-specific descriptor polish already tracked separately.

Keep flexible: the fix should leave room for shared exotic-object hooks used by TypedArray/String wrappers instead of baking all behavior into codegen call sites.

Suggested scope

Acceptance criteria

  • The representative rows above pass under the Test262 differential.
  • built-ins/Array --max 180 improves materially without relying on skiplist changes.
  • Existing Perry parity fixtures for normal arrays continue to pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions