Skip to content

Commit

Permalink
Validate mutability in DetachArrayBuffer (#38)
Browse files Browse the repository at this point in the history
Ref #30
  • Loading branch information
gibson042 authored Feb 15, 2025
1 parent 3c049b9 commit e858846
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,31 @@ contributors: Mark S. Miller, Richard Gibson
</emu-clause>
</ins>

<emu-clause id="sec-detacharraybuffer" type="abstract operation" number="5">
<h1>
DetachArrayBuffer (
_arrayBuffer_: an ArrayBuffer,
optional _key_: anything,
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
<dt>skip global checks</dt>
<dd>true</dd>
</dl>
<emu-alg>
1. Assert: IsSharedArrayBuffer(_arrayBuffer_) is *false*.
1. If _key_ is not present, set _key_ to *undefined*.
1. If _arrayBuffer_.[[ArrayBufferDetachKey]] is not _key_, throw a *TypeError* exception.
1. <ins>If IsImmutableBuffer(_arrayBuffer_) is *true*, throw a *TypeError* exception.</ins>
1. Set _arrayBuffer_.[[ArrayBufferData]] to *null*.
1. Set _arrayBuffer_.[[ArrayBufferByteLength]] to 0.
1. Return ~unused~.
</emu-alg>
<emu-note>
<p>Detaching an ArrayBuffer instance disassociates the Data Block used as its backing store from the instance and sets the byte length of the buffer to 0.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-setvalueinbuffer" type="abstract operation" number="18">
<h1>
SetValueInBuffer (
Expand Down

0 comments on commit e858846

Please sign in to comment.