ReviewOS

zig-utils/zig-js

TypedArray: honor inherited indexed Get and HasProperty

#1059
Closed chris opened this 9 days ago ·
9 days ago

Parent: #498 Related: #1054, #1057, #1058

The generic prototype walker does not delegate canonical numeric keys to TypedArray exotic Get/HasProperty when the TypedArray is an ancestor.

Executed nine-assertion probe: Node returns nine true values. The saved before binary returns false,false,true,false,false,false,true,false,false in both tree and required-bytecode modes. An Array/ordinary object inheriting from new Uint8Array([7]) reads undefined at index 0; invalid indices 1 and String -0 observe higher getters/properties instead of stopping at the TypedArray.

Acceptance:

  • Valid inherited numeric reads load the TypedArray's own element with the original receiver preserved for ordinary non-indexed getters.
  • Invalid canonical indices terminate Get/HasProperty at a TypedArray ancestor without observing higher getters/has traps.
  • Pin Array/ordinary/primitive receivers, deeper chains, BigInt views, invalid/canonical/noncanonical keys, detach/resize, own precedence, Proxy boundaries, and restriction ownership against Node.
  • Normal/unsuppressed TSan tests and targeted before/after Test262 checks pass.

Additional executed before probe: Number, Boolean, Symbol, and BigInt primitives inheriting from a Uint8Array all return false for the expected element read in both modes; Node returns true for all four. The repair shares IntegerIndexedElementGet across direct, inherited, primitive, and VM reads.

9 days ago

Fixed in b444e46.

Canonical numeric Get/HasProperty now terminates at a TypedArray ancestor, yielding its element or an invalid-index miss before any higher getter or Proxy trap. Direct, inherited, primitive, and VM reads share IntegerIndexedElementGet. Ordinary named properties keep their original receiver and prototype behavior.

Measured evidence:

  • The original nine-assertion probe plus four primitive-receiver assertions changed from 11 failures to all 13 matching Node in both tree and required-bytecode modes.
  • Six Node-confirmed matrices cover Array/ordinary/primitive receivers, deeper chains, BigInt, invalid/noncanonical keys, own precedence, resize/detach, Proxy boundaries, and getter receiver identity.
  • VM TypedArray coverage passes 11/11 normally and under unsuppressed TSan, including prototype restriction ownership. The interpreter fixture passes 2/2 in both builds.
  • Before/after Test262: TypedArray internals 240, Reflect.get 11, Reflect.has 10, and in expressions 36. All 297 cases pass on both sides, with zero flips and byte-identical outputs.
  • The 240-case TypedArray tree/VM witness has zero divergences on both sides. The quickening inventory gate passes.

Sign in to comment on this issue.