Skip to content

Commit 32921f6

Browse files
committed
Normative: Always report assignment failure to canonical numeric string properties of immutable-backed TypedArray instances
Note that this includes non-integer-index but still canonical numeric properties such as "-0", "-1", "1.2", and String(2**53) = "9007199254740992", but does not include non-canonical-numeric properties such as "1.20", "1e3", and "0x20". Ideally, TypedArrays would restrict special treatment of canonical numeric string properties to the strict subset that are integer indices (aligning with similar treatment in String), but that is out of scope for this commit.
1 parent db0ec14 commit 32921f6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec.emu

+5-3
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ contributors: Mark S. Miller, Richard Gibson
131131
1. If _P_ is a String, then
132132
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
133133
1. If _numericIndex_ is not *undefined*, then
134+
1. <ins>NOTE: TypedArray instances restrict own and inherited canonical numeric string properties to integer indices valid for their backing buffers, but assignment failures for canonical numeric string properties are only reported when the buffer is immutable.</ins>
135+
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, return *false*.</ins>
134136
1. If SameValue(_O_, _Receiver_) is *true*, then
135-
1. <ins>IsValidIntegerIndex(_O_, _numericIndex_) is *true* and IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, return *false*.</ins>
136137
1. Perform ? TypedArraySetElement(_O_, _numericIndex_, _V_).
137138
1. Return *true*.
138139
1. If IsValidIntegerIndex(_O_, _numericIndex_) is *false*, return *true*.
@@ -151,9 +152,10 @@ contributors: Mark S. Miller, Richard Gibson
151152
<dl class="header">
152153
</dl>
153154
<emu-alg>
155+
1. <ins>Assert: IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*.</ins>
154156
1. If _O_.[[ContentType]] is ~bigint~, let _numValue_ be ? ToBigInt(_value_).
155157
1. Otherwise, let _numValue_ be ? ToNumber(_value_).
156-
1. If IsValidIntegerIndex(_O_, _index_) is *true* <ins>and IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*</ins>, then
158+
1. If IsValidIntegerIndex(_O_, _index_) is *true*, then
157159
1. Let _offset_ be _O_.[[ByteOffset]].
158160
1. Let _elementSize_ be TypedArrayElementSize(_O_).
159161
1. Let _byteIndexInBuffer_ be (ℝ(_index_) × _elementSize_) + _offset_.
@@ -162,7 +164,7 @@ contributors: Mark S. Miller, Richard Gibson
162164
1. Return ~unused~.
163165
</emu-alg>
164166
<emu-note>
165-
<p>This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached <ins>or immutable</ins> ArrayBuffer.</p>
167+
<p>This operation always appears to succeed, but it has no effect when attempting to write past the end of a TypedArray or to a TypedArray which is backed by a detached ArrayBuffer.</p>
166168
</emu-note>
167169
</emu-clause>
168170
</emu-clause>

0 commit comments

Comments
 (0)