Skip to content

Commit 8ba1536

Browse files
committed
Editorial: Better align ArrayBuffer.p.sliceToImmutable with slice
1 parent 0e49bdf commit 8ba1536

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

spec.emu

+6-5
Original file line numberDiff line numberDiff line change
@@ -717,19 +717,20 @@ contributors: Mark S. Miller, Richard Gibson
717717
1. Let _O_ be the *this* value.
718718
1. Perform ? RequireInternalSlot(_O_, [[ArrayBufferData]]).
719719
1. If IsSharedArrayBuffer(_O_) is *true*, throw a *TypeError* exception.
720-
1. TODO: Confirm inclusion of this redundant check.
721720
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
722721
1. Let _len_ be _O_.[[ArrayBufferByteLength]].
723722
1. Let _bounds_ be ? ResolveBounds(_len_, _start_, _end_).
724723
1. Let _first_ be _bounds_.[[From]].
725724
1. Let _final_ be _bounds_.[[To]].
726-
1. TODO: Confirm this strictness vs. the conventional `max(_final_ - _first_, 0)`.
727725
1. Let _newLen_ be _final_ - _first_.
726+
1. TODO: Confirm this strictness vs. `slice` (rejecting negative _newLen_ rather than clamping to 0).
728727
1. If _newLen_ < 0, throw a *RangeError* exception.
729-
1. Let _copyLen_ be min(_newLen_, _len_).
730-
1. NOTE: Side-effects of the above steps may have detached or resized _O_. This algorithm proceeds only when _O_ is not detached, even if _newLen_ is 0.
728+
1. NOTE: Side-effects of the above steps may have detached or resized _O_.
731729
1. If IsDetachedBuffer(_O_) is *true*, throw a *TypeError* exception.
732-
1. Let _newBuffer_ be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, _newLen_, _O_.[[ArrayBufferData]], _first_, _copyLen_).
730+
1. Let _fromBuf_ be _O_.[[ArrayBufferData]].
731+
1. Let _currentLen_ be _O_.[[ArrayBufferByteLength]].
732+
1. If _currentLen_ < _final_, throw a *RangeError* exception.
733+
1. Let _newBuffer_ be ? AllocateImmutableArrayBuffer(%ArrayBuffer%, _newLen_, _fromBuf_, _first_, _newLen_).
733734
1. Return _newBuffer_.
734735
</emu-alg>
735736
</emu-clause>

0 commit comments

Comments
 (0)