Skip to content
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

Editorial: fix an invariant for [[GetOwnProperty]] #3254

Merged
merged 1 commit into from
Feb 14, 2024
Merged

Conversation

bakkot
Copy link
Contributor

@bakkot bakkot commented Jan 10, 2024

Fixes #3253.

Calling this editorial because it's not currently coherent with text in the surrounding section. It's debatably normative though.

The constraints are sometimes worded in a slightly confusing way. The intended constraints on GetOwnProperty are:

  • No constraints on how configurable: true properties can change
  • configurable: false + writable: true properties can change value and can become non-writable, but no other changes are allowed
  • configurable: false + (writable: false or accessor) properties cannot change in any way
  • properties cannot be created on non-extensible objects

These are clearly the intended constraints, especially if you read the NOTE:

As a consequence of the third invariant, if a property is described as a data property and it may return different values over time, then either or both of the [[Writable]] and [[Configurable]] attributes must be true even if no mechanism to change the value is exposed via the other essential internal methods.

Currently the wording for one of the invariants says that if any property other than [[Writable]] can change then it must be configurable. But that doesn't match the intended constraints: in fact the [[Value]] should be able to change as well when the property is writable, even for non-configurable properties.

(The fact that [[Value]] can't change for non-writable non-configurable properties is already covered by the invariant before this one.)


Sidebar: maybe we should rework this section to be easier to understand.

@mhofman
Copy link
Member

mhofman commented Jan 10, 2024

  • configurable: false + writable: false properties cannot change in any way

Nit: if configurable === false and writable !== true, properties cannot change in any way

Otherwise accessor properties are not covered.

@bakkot
Copy link
Contributor Author

bakkot commented Jan 10, 2024

Updated the description, thanks.

Copy link
Member

@michaelficarra michaelficarra left a comment

Choose a reason for hiding this comment

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

I don't like the wording in this section.

@bakkot bakkot added the es2024 to be landed before es2024 label Feb 14, 2024
@michaelficarra michaelficarra added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Feb 14, 2024
@ljharb ljharb force-pushed the fix-gop-constraint branch from 35c0ed4 to 84f6234 Compare February 14, 2024 22:44
@ljharb ljharb merged commit 84f6234 into main Feb 14, 2024
@ljharb ljharb deleted the fix-gop-constraint branch February 14, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change es2024 to be landed before es2024 ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Object invariants disallow changing non-configurable but writable data property's value
5 participants