Summary
new TypedArray(object) where object is an iterable or an array-like (not a TypedArray, ArrayBuffer, or GocciaScript Array) falls through to the numeric-length construction path instead of following ES2026 §23.2.5.1 steps 5-6. The object is coerced to a number via ToNumberLiteral, producing NaN → length 0.
Why
The spec requires two object paths:
- Step 5a: If the object has
@@iterator, iterate it and construct from the values.
- Step 5b: Otherwise, treat it as an array-like: read
length, then Get(obj, k) for each index.
Both paths are missing. This affects any code that constructs typed arrays from plain iterables or array-like objects, and causes 4 test262 conformance failures where the bundled testTypedArray.js harness factories produce length-0 arrays instead of the intended length-1.
Current behavior
./build.pas loaderbare
printf 'print(new Int32Array({0: 7, length: 1}).length);\n' | ./build/GocciaScriptLoaderBare --asi --compat-all
# 0
printf 'print(new Int32Array([7][Symbol.iterator]()).length);\n' | ./build/GocciaScriptLoaderBare --asi --compat-all
# 0
Expected behavior
Scope notes
The constructor in TGocciaTypedArrayClassValue.CreateNativeInstance (source/units/Goccia.Values.TypedArrayValue.pas:1967) handles TypedArray, ArrayBuffer, SharedArrayBuffer, and GocciaScript Array, then falls through to the numeric-length path. The fix adds two branches before the fallback: check @@iterator (construct from iterable), then array-like (read length + indexed Get).
Blocked test262 tests (currently failing via the testTypedArray.js harness makeArrayLike and makeIterable factories):
TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js (+ BigInt variant)
TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js
TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js
Surfaced by #526 which added a spec-correct FLength = 0 early return to TypedArray search methods.
Summary
new TypedArray(object)whereobjectis an iterable or an array-like (not a TypedArray, ArrayBuffer, or GocciaScript Array) falls through to the numeric-length construction path instead of following ES2026 §23.2.5.1 steps 5-6. The object is coerced to a number viaToNumberLiteral, producing NaN → length 0.Why
The spec requires two object paths:
@@iterator, iterate it and construct from the values.length, thenGet(obj, k)for each index.Both paths are missing. This affects any code that constructs typed arrays from plain iterables or array-like objects, and causes 4 test262 conformance failures where the bundled
testTypedArray.jsharness factories produce length-0 arrays instead of the intended length-1.Current behavior
Expected behavior
Scope notes
The constructor in
TGocciaTypedArrayClassValue.CreateNativeInstance(source/units/Goccia.Values.TypedArrayValue.pas:1967) handles TypedArray, ArrayBuffer, SharedArrayBuffer, and GocciaScript Array, then falls through to the numeric-length path. The fix adds two branches before the fallback: check@@iterator(construct from iterable), then array-like (readlength+ indexed Get).Blocked test262 tests (currently failing via the
testTypedArray.jsharnessmakeArrayLikeandmakeIterablefactories):TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js(+ BigInt variant)TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.jsTypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.jsSurfaced by #526 which added a spec-correct
FLength = 0early return to TypedArray search methods.