Summary
TypedArray constructor and prototype built-in members should be non-enumerable. Today several members are enumerable, so for...in over a typed array yields inherited built-in names such as BYTES_PER_ELEMENT, toBase64, and toHex.
Why
Enabling --compat-for-in-loop surfaced newly failing test262 coverage:
built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.js
built-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.js
Those tests expect detached typed arrays to enumerate zero keys. Goccia correctly skips numeric indexed elements after detachment, but inherited enumerable TypedArray built-ins still leak through enumeration.
Current behavior
With the current branch:
printf 'const sample = new Uint8Array(3); sample.buffer.transfer(); for (const k in sample) print(k);\n' | \
./build/GocciaScriptLoaderBare \
--compat-for-in-loop --compat-var --compat-function \
--compat-traditional-for-loop --compat-while-loops \
--compat-loose-equality --compat-label --compat-non-strict-mode \
--unsafe-function-constructor --mode=bytecode -
prints:
BYTES_PER_ELEMENT
toBase64
toHex
setFromBase64
setFromHex
A descriptor probe also shows TypedArray built-ins are enumerable:
Object.getOwnPropertyDescriptor(Uint8Array.prototype, "toHex").enumerable // true
Object.getOwnPropertyDescriptor(Uint8Array, "BYTES_PER_ELEMENT").enumerable // true
Expected behavior
TypedArray constructor and prototype built-in properties should use ECMAScript descriptor attributes, with built-in methods and constants non-enumerable. for...in over a detached typed array should not yield inherited TypedArray built-in names.
Scope notes
Likely fix area: source/units/Goccia.Values.TypedArrayValue.pas and shared object-model member installation paths. Check both constructor properties (BYTES_PER_ELEMENT, from, of, base64/hex helpers) and prototype properties (BYTES_PER_ELEMENT, toBase64, toHex, setFromBase64, setFromHex) across numeric and BigInt typed arrays.
Summary
TypedArray constructor and prototype built-in members should be non-enumerable. Today several members are enumerable, so
for...inover a typed array yields inherited built-in names such asBYTES_PER_ELEMENT,toBase64, andtoHex.Why
Enabling
--compat-for-in-loopsurfaced newly failing test262 coverage:built-ins/TypedArrayConstructors/internals/GetOwnProperty/enumerate-detached-buffer.jsbuilt-ins/TypedArrayConstructors/internals/GetOwnProperty/BigInt/enumerate-detached-buffer.jsThose tests expect detached typed arrays to enumerate zero keys. Goccia correctly skips numeric indexed elements after detachment, but inherited enumerable TypedArray built-ins still leak through enumeration.
Current behavior
With the current branch:
prints:
A descriptor probe also shows TypedArray built-ins are enumerable:
Expected behavior
TypedArray constructor and prototype built-in properties should use ECMAScript descriptor attributes, with built-in methods and constants non-enumerable.
for...inover a detached typed array should not yield inherited TypedArray built-in names.Scope notes
Likely fix area:
source/units/Goccia.Values.TypedArrayValue.pasand shared object-model member installation paths. Check both constructor properties (BYTES_PER_ELEMENT,from,of, base64/hex helpers) and prototype properties (BYTES_PER_ELEMENT,toBase64,toHex,setFromBase64,setFromHex) across numeric and BigInt typed arrays.