generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
https://tc39.es/ecma262/#sec-%typedarray%.prototype.filter:
- Let A be ? TypedArraySpeciesCreate(O, « 𝔽(captured) »).
- Let n be 0.
- For each element e of kept, do
a. Perform ! Set(A, ! ToString(𝔽(n)), e, true).
b. Set n to n + 1.
If A
is an immutable TypedArray object, then Set
can return with an abrupt completion, so using ! Set
is no longer correct.
Other callers to TypedArraySpeciesCreate
:
- https://tc39.es/ecma262/#sec-%typedarray%.prototype.slice also needs to be updated.
- https://tc39.es/ecma262/#sec-%typedarray%.prototype.map already uses
? Set
.
I guess the simplest fix is to update https://tc39.es/ecma262/#sec-typedarraycreatefromconstructor and add a new step 3.d:
3.d. If IsImmutableBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception
Or rewriting TypedArrayCreateFromConstructor
to pass the correct access-mode:
- If the number of elements in argumentList is 1 and argumentList[0] is a Number, then
a. Let accessMode be WRITE.- Else,
b. Let accessMode be READ.- Let newTypedArray be ? Construct(constructor, argumentList).
- Let taRecord be ? ValidateTypedArray(newTypedArray, seq-cst, accessMode).
- If accessMode is WRITE, then
a. Assert: IsTypedArrayOutOfBounds(taRecord) is false.
b. Let length be TypedArrayLength(taRecord).
c. If length < ℝ(argumentList[0]), throw a TypeError exception.- Return newTypedArray.
Drive-by change: Update step 5.a. to use Assert, because ValidateTypedArray already throws for out-of-bounds.
Metadata
Metadata
Assignees
Labels
No labels