Skip to content

Editorial: Split TypedArray [[DefineOwnProperty]] into distinct branches by mutability #32

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

Merged
merged 2 commits into from
Feb 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,16 @@ contributors: Mark S. Miller, Richard Gibson
1. Let _numericIndex_ be CanonicalNumericIndexString(_P_).
1. If _numericIndex_ is not *undefined*, then
1. If IsValidIntegerIndex(_O_, _numericIndex_) is *false*, return *false*.
1. <ins>Let _mutable_ be *true*.</ins>
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, set _mutable_ to *false*.</ins>
1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is <del>*false*</del> <ins>not _mutable_</ins>, return *false*.
1. <ins>If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, then</ins>
1. <ins>Let _current_ be ! <emu-meta suppress-effects="user-code">_O_.[[GetOwnProperty]](_P_)</emu-meta>.</ins>
1. <ins>Assert: _current_.[[Configurable]] and _current_.[[Writable]] are both *false*.</ins>
1. <ins>NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.</ins>
1. <ins>Return ValidateAndApplyPropertyDescriptor(_O_, _P_, *false*, _Desc_, _current_).</ins>
1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is *false*, return *false*.
1. If _Desc_ has an [[Enumerable]] field and _Desc_.[[Enumerable]] is *false*, return *false*.
1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*.
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is <del>*false*</del> <ins>not _mutable_</ins>, return *false*.
1. <del>If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).</del>
1. <ins>If _Desc_ has a [[Value]] field, then</ins>
1. <ins>NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value.</ins>
1. <ins>If _mutable_ is *false* and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*.</ins>
1. <ins>If _mutable_ is *true*, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).</ins>
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *false*, return *false*.
1. If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]).
1. Return *true*.
1. Return ! OrdinaryDefineOwnProperty(_O_, _P_, _Desc_).
</emu-alg>
Expand Down