Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

spec: rename CreateNonEnumerableDataProperty to CreateNonEnumerableDataPropertyOrThrow #27

Merged
merged 2 commits into from
Mar 5, 2021

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Mar 3, 2021

Update abstract operation CreateNonEnumerableDataProperty with name CreateNonEnumerableDataPropertyOrThrow to indicate the AO is throwing on unable to perform the creation.

Refs: #2 (comment)

@legendecas legendecas force-pushed the fix-create-non-enumerable-data-property branch from 4eb4ba9 to 79f07b7 Compare March 3, 2021 11:34
spec.emu Outdated
1. <ins>Let _newDesc_ be the PropertyDescriptor { [[Value]]: _V_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.</ins>
1. <ins>Return ? DefinePropertyOrThrow(_O_, _P_, _newDesc_).</ins>
1. <ins>Return ? ? _O_.[[DefineOwnProperty]](_P_, _newDesc_).</ins>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an improvement? The behavior of returning false on failure has caused a number of spec bugs, which is why most of them have been changed to call DefinePropertyOrThrow with ?.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the linked comment, the AO should have an “OrThrow” in the name, rather than not throwing at all.

@legendecas legendecas force-pushed the fix-create-non-enumerable-data-property branch from 42855a1 to 71e533d Compare March 4, 2021 16:37
@legendecas legendecas changed the title spec: CreateNonEnumerableDataProperty with [[DefineOwnProperty]] spec: rename CreateNonEnumerableDataProperty to CreateNonEnumerableDataPropertyOrThrow Mar 4, 2021
@legendecas
Copy link
Member Author

@ljharb thanks for the context. I've updated the PR with renaming the AO to indicate they are throwing on failure.

spec.emu Outdated
<p><ins>The abstract operation CreateNonEnumerableDataProperty takes arguments _O_ (an Object), _P_ (a property key), and _V_ (an ECMAScript language value). It performs the following steps when called:</ins></p>
<emu-clause id="sec-createnonenumerabledatapropertyorthrow">
<h1><ins>CreateNonEnumerableDataPropertyOrThrow ( _O_, _P_, _V_ )</ins></h1>
<p><ins>The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments _O_ (an Object), _P_ (a property key), and _V_ (an ECMAScript language value). It is used to create a new non-enumerable own property of an object. It throws a *TypeError* exception if the requested property update cannot be performed. It performs the following steps when called:</ins></p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<p><ins>The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments _O_ (an Object), _P_ (a property key), and _V_ (an ECMAScript language value). It is used to create a new non-enumerable own property of an object. It throws a *TypeError* exception if the requested property update cannot be performed. It performs the following steps when called:</ins></p>
<p><ins>The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments _O_ (an Object), _P_ (a Property Key), and _V_ (an ECMAScript language value). It is used to create a new non-enumerable own property of an object. It throws a *TypeError* exception if the requested property update cannot be performed. It performs the following steps when called:</ins></p>

spec.emu Outdated
Comment on lines 50 to 51
1. <ins>Assert: Type(_O_) is Object.</ins>
1. <ins>Assert: IsPropertyKey(_P_) is true.</ins>
1. <ins>Assert: IsPropertyKey(_P_) is *true*.</ins>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two can be removed, since they're now redundant

@legendecas legendecas force-pushed the fix-create-non-enumerable-data-property branch from 15d303e to 6aaffb9 Compare March 4, 2021 17:17
@legendecas legendecas force-pushed the fix-create-non-enumerable-data-property branch from 6aaffb9 to 9192e7a Compare March 4, 2021 17:18
@legendecas legendecas merged commit 5596f49 into main Mar 5, 2021
@legendecas legendecas deleted the fix-create-non-enumerable-data-property branch March 5, 2021 02:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants