From 342bae08c9ee4d03eed2e0ef4d54d3d251d06c62 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sat, 15 Feb 2025 11:06:13 -0500 Subject: [PATCH 1/2] Editorial: Split TypedArray [[DefineOwnProperty]] into distinct branches by mutability --- spec.emu | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/spec.emu b/spec.emu index c3d88b7..60dbea3 100644 --- a/spec.emu +++ b/spec.emu @@ -99,18 +99,21 @@ 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. Let _mutable_ be *true*. - 1. If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, set _mutable_ to *false*. - 1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is *false* not _mutable_, 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 *false* not _mutable_, return *false*. - 1. If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]). - 1. If _Desc_ has a [[Value]] field, then + 1. If _Desc_ has an [[Enumerable]] field and _Desc_.[[Enumerable]] is *false*, return *false*. + 1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*. + 1. If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*, then + 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 *false*, return *false*. + 1. If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]). + 1. Return *true*. + 1. Else, + 1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is *true*, return *false*. + 1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *true*, return *false*. 1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value. - 1. If _mutable_ is *false* and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*. - 1. If _mutable_ is *true*, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]). - 1. Return *true*. + 1. If _Desc_ has a [[Value]] field and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*. + 1. Return *true*. 1. Return ! OrdinaryDefineOwnProperty(_O_, _P_, _Desc_). From e2315160233514d7c68c17cf32cf8a83df2e2867 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Sat, 15 Feb 2025 11:06:13 -0500 Subject: [PATCH 2/2] Editorial: Defer the TypedArray [[DefineOwnProperty]] immutable branch to ValidateAndApplyPropertyDescriptor --- spec.emu | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/spec.emu b/spec.emu index 60dbea3..475cd19 100644 --- a/spec.emu +++ b/spec.emu @@ -99,21 +99,17 @@ 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. If _Desc_ has an [[Enumerable]] field and _Desc_.[[Enumerable]] is *false*, return *false*. - 1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*. - 1. If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *false*, then - 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 *false*, return *false*. - 1. If _Desc_ has a [[Value]] field, perform ? TypedArraySetElement(_O_, _numericIndex_, _Desc_.[[Value]]). - 1. Return *true*. - 1. Else, - 1. If _Desc_ has a [[Configurable]] field and _Desc_.[[Configurable]] is *true*, return *false*. - 1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *true*, return *false*. + 1. If IsImmutableBuffer(_O_.[[ViewedArrayBuffer]]) is *true*, then + 1. Let _current_ be ! _O_.[[GetOwnProperty]](_P_). + 1. Assert: _current_.[[Configurable]] and _current_.[[Writable]] are both *false*. 1. NOTE: Attempting to redefine an immutable value always fails, even if the new value would be cast to the current value. - 1. If _Desc_ has a [[Value]] field and SameValue(_Desc_.[[Value]], TypedArrayGetElement(_O_, _numericIndex_)) is *false*, return *false*. - 1. Return *true*. + 1. Return ValidateAndApplyPropertyDescriptor(_O_, _P_, *false*, _Desc_, _current_). + 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 *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_).