-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: Remove Species check for TypedArrays ArrayBuffers and SharedArrayBuffers #3450
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6572,6 +6572,9 @@ <h1> | |||||
1. If IsConstructor(_S_) is *true*, return _S_. | ||||||
1. Throw a *TypeError* exception. | ||||||
</emu-alg> | ||||||
<emu-note> | ||||||
<p>Species constructor is only available for Array, RegExp, and Promise built-in classes. </p> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</emu-note> | ||||||
</emu-clause> | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Editors discussed this and we think that capturing "we aren't going to do this anymore" probably doesn't belong in the spec itself. Instead, how-we-work/normative-conventions.md would be a good place for capturing this for the committee's benefit, and MDN for the community's. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this note be removed entirely or should the comment about species constructor availability stay? |
||||||
<emu-clause id="sec-enumerableownproperties" type="abstract operation" oldids="sec-enumerableownpropertynames"> | ||||||
|
@@ -40793,7 +40796,7 @@ <h1>%TypedArray%.prototype.filter ( _callback_ [ , _thisArg_ ] )</h1> | |||||
1. Append _kValue_ to _kept_. | ||||||
1. Set _captured_ to _captured_ + 1. | ||||||
1. Set _k_ to _k_ + 1. | ||||||
1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_captured_) »). | ||||||
1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_captured_) »). | ||||||
1. Let _n_ be 0. | ||||||
1. For each element _e_ of _kept_, do | ||||||
1. Perform ! Set(_A_, ! ToString(𝔽(_n_)), _e_, *true*). | ||||||
|
@@ -41019,7 +41022,7 @@ <h1>%TypedArray%.prototype.map ( _callback_ [ , _thisArg_ ] )</h1> | |||||
1. Let _taRecord_ be ? ValidateTypedArray(_O_, ~seq-cst~). | ||||||
1. Let _len_ be TypedArrayLength(_taRecord_). | ||||||
1. If IsCallable(_callback_) is *false*, throw a *TypeError* exception. | ||||||
1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_len_) »). | ||||||
1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_len_) »). | ||||||
1. Let _k_ be 0. | ||||||
1. Repeat, while _k_ < _len_, | ||||||
1. Let _Pk_ be ! ToString(𝔽(_k_)). | ||||||
|
@@ -41235,7 +41238,7 @@ <h1>%TypedArray%.prototype.slice ( _start_, _end_ )</h1> | |||||
1. Else if _relativeEnd_ < 0, let _endIndex_ be max(_srcArrayLength_ + _relativeEnd_, 0). | ||||||
1. Else, let _endIndex_ be min(_relativeEnd_, _srcArrayLength_). | ||||||
1. Let _countBytes_ be max(_endIndex_ - _startIndex_, 0). | ||||||
1. Let _A_ be ? TypedArraySpeciesCreate(_O_, « 𝔽(_countBytes_) »). | ||||||
1. Let _A_ be ? TypedArrayCreateSameType(_O_, « 𝔽(_countBytes_) »). | ||||||
1. If _countBytes_ > 0, then | ||||||
1. Set _taRecord_ to MakeTypedArrayWithBufferWitnessRecord(_O_, ~seq-cst~). | ||||||
1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, throw a *TypeError* exception. | ||||||
|
@@ -41347,7 +41350,7 @@ <h1>%TypedArray%.prototype.subarray ( _start_, _end_ )</h1> | |||||
1. Else, let _endIndex_ be min(_relativeEnd_, _srcLength_). | ||||||
1. Let _newLength_ be max(_endIndex_ - _startIndex_, 0). | ||||||
1. Let _argumentsList_ be « _buffer_, 𝔽(_beginByteOffset_), 𝔽(_newLength_) ». | ||||||
1. Return ? TypedArraySpeciesCreate(_O_, _argumentsList_). | ||||||
1. Return ? TypedArrayCreateSameType(_O_, _argumentsList_). | ||||||
</emu-alg> | ||||||
<p>This method is not generic. The *this* value must be an object with a [[TypedArrayName]] internal slot.</p> | ||||||
</emu-clause> | ||||||
|
@@ -41465,27 +41468,6 @@ <h1>get %TypedArray%.prototype [ %Symbol.toStringTag% ]</h1> | |||||
<emu-clause id="sec-abstract-operations-for-typedarray-objects"> | ||||||
<h1>Abstract Operations for TypedArray Objects</h1> | ||||||
|
||||||
<emu-clause id="typedarray-species-create" type="abstract operation"> | ||||||
<h1> | ||||||
TypedArraySpeciesCreate ( | ||||||
_exemplar_: a TypedArray, | ||||||
_argumentList_: a List of ECMAScript language values, | ||||||
): either a normal completion containing a TypedArray or a throw completion | ||||||
</h1> | ||||||
<dl class="header"> | ||||||
<dt>description</dt> | ||||||
<dd>It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. Unlike ArraySpeciesCreate, which can create non-Array objects through the use of %Symbol.species%, this operation enforces that the constructor function creates an actual TypedArray.</dd> | ||||||
</dl> | ||||||
<emu-alg> | ||||||
1. Let _defaultConstructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in <emu-xref href="#table-the-typedarray-constructors"></emu-xref>. | ||||||
1. Let _constructor_ be ? SpeciesConstructor(_exemplar_, _defaultConstructor_). | ||||||
1. Let _result_ be ? TypedArrayCreateFromConstructor(_constructor_, _argumentList_). | ||||||
1. Assert: _result_ has [[TypedArrayName]] and [[ContentType]] internal slots. | ||||||
1. If _result_.[[ContentType]] is not _exemplar_.[[ContentType]], throw a *TypeError* exception. | ||||||
1. Return _result_. | ||||||
</emu-alg> | ||||||
</emu-clause> | ||||||
|
||||||
<emu-clause id="sec-typedarraycreatefromconstructor" oldids="typedarray-create" type="abstract operation"> | ||||||
<h1> | ||||||
TypedArrayCreateFromConstructor ( | ||||||
|
@@ -41508,7 +41490,7 @@ <h1> | |||||
</emu-alg> | ||||||
</emu-clause> | ||||||
|
||||||
<emu-clause id="sec-typedarray-create-same-type" type="abstract operation"> | ||||||
<emu-clause id="sec-typedarray-create-same-type" oldids="typedarray-species-create" type="abstract operation"> | ||||||
<h1> | ||||||
TypedArrayCreateSameType ( | ||||||
_exemplar_: a TypedArray, | ||||||
|
@@ -41517,7 +41499,7 @@ <h1> | |||||
</h1> | ||||||
<dl class="header"> | ||||||
<dt>description</dt> | ||||||
<dd>It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. Unlike TypedArraySpeciesCreate, which can construct custom TypedArray subclasses through the use of %Symbol.species%, this operation always uses one of the built-in TypedArray constructors.</dd> | ||||||
<dd>It is used to specify the creation of a new TypedArray using a constructor function that is derived from _exemplar_. This operation always uses one of the built-in TypedArray constructors. Prior to the 2025 edition of the specification some TypedArray methods made use of SpeciesCreate, but that functionality has been removed.</dd> | ||||||
bakkot marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
</dl> | ||||||
<emu-alg> | ||||||
1. Let _constructor_ be the intrinsic object associated with the constructor name _exemplar_.[[TypedArrayName]] in <emu-xref href="#table-the-typedarray-constructors"></emu-xref>. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
@@ -43807,8 +43789,7 @@ <h1>ArrayBuffer.prototype.slice ( _start_, _end_ )</h1> | |||||
1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). | ||||||
1. Else, let _final_ be min(_relativeEnd_, _len_). | ||||||
1. Let _newLen_ be max(_final_ - _first_, 0). | ||||||
1. Let _ctor_ be ? SpeciesConstructor(_O_, %ArrayBuffer%). | ||||||
1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). | ||||||
1. Let _new_ be ? Construct(%ArrayBuffer%, « 𝔽(_newLen_) »). | ||||||
1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). | ||||||
1. If IsSharedArrayBuffer(_new_) is *true*, throw a *TypeError* exception. | ||||||
1. If IsDetachedBuffer(_new_) is *true*, throw a *TypeError* exception. | ||||||
|
@@ -44125,8 +44106,7 @@ <h1>SharedArrayBuffer.prototype.slice ( _start_, _end_ )</h1> | |||||
1. Else if _relativeEnd_ < 0, let _final_ be max(_len_ + _relativeEnd_, 0). | ||||||
1. Else, let _final_ be min(_relativeEnd_, _len_). | ||||||
1. Let _newLen_ be max(_final_ - _first_, 0). | ||||||
1. Let _ctor_ be ? SpeciesConstructor(_O_, %SharedArrayBuffer%). | ||||||
1. Let _new_ be ? Construct(_ctor_, « 𝔽(_newLen_) »). | ||||||
1. Let _new_ be ? Construct(%SharedArrayBuffer%, « 𝔽(_newLen_) »). | ||||||
1. Perform ? RequireInternalSlot(_new_, [[ArrayBufferData]]). | ||||||
1. If IsSharedArrayBuffer(_new_) is *false*, throw a *TypeError* exception. | ||||||
1. If _new_.[[ArrayBufferData]] is _O_.[[ArrayBufferData]], throw a *TypeError* exception. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.