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: Don't allow writing NaN to frozen properties #3404

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

anba
Copy link
Contributor

@anba anba commented Aug 26, 2024

If an implementation can produce distinguishable NaN values, then writing NaN values to a frozen (non-configurable and non-writable) property can be detectable.

This is a regression from #2468.

@michaelficarra michaelficarra requested a review from a team August 26, 2024 16:42
spec.html Outdated
@@ -12748,7 +12748,7 @@ <h1>
1. If _Desc_ has a [[Set]] field and SameValue(_Desc_.[[Set]], _current_.[[Set]]) is *false*, return *false*.
1. Else if _current_.[[Writable]] is *false*, then
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *true*, return *false*.
1. If _Desc_ has a [[Value]] field and SameValue(_Desc_.[[Value]], _current_.[[Value]]) is *false*, return *false*.
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a note to discourage future would-be refactorings?

Copy link
Member

Choose a reason for hiding this comment

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

Unless you have a concrete suggestion on hand, I'd rather not delay this indefinitely. We could always add the note in a follow-up, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

NOTE: The following is not equivalent to returning false when SameValue returns false in the case of NaN.

Copy link
Member

Choose a reason for hiding this comment

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

Nah, I don't like that wording. I'd say something like "the following step must not fall through to the property configuration steps below, even when SameValue returns true, because NaN values may be distinguishable".

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).
1. NOTE: SameValue returns true for *NaN* values which may be distinguishable by other means. Returning here ensures that any existing property of _O_ remains unmodified.
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).

Copy link
Member

Choose a reason for hiding this comment

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

That also WFM.

Copy link
Member

Choose a reason for hiding this comment

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

*true* btw

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, wfm too.

Copy link
Contributor

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

Nice catch!

spec.html Outdated
@@ -12748,7 +12748,7 @@ <h1>
1. If _Desc_ has a [[Set]] field and SameValue(_Desc_.[[Set]], _current_.[[Set]]) is *false*, return *false*.
1. Else if _current_.[[Writable]] is *false*, then
1. If _Desc_ has a [[Writable]] field and _Desc_.[[Writable]] is *true*, return *false*.
1. If _Desc_ has a [[Value]] field and SameValue(_Desc_.[[Value]], _current_.[[Value]]) is *false*, return *false*.
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).
1. NOTE: SameValue returns true for *NaN* values which may be distinguishable by other means. Returning here ensures that any existing property of _O_ remains unmodified.
1. If _Desc_ has a [[Value]] field, return SameValue(_Desc_.[[Value]], _current_.[[Value]]).

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 27, 2024
…spidermonkey-reviewers,jandem

`ValidateAndApplyPropertyDescriptor` was refactored in <tc39/ecma262#2468>,
make sure our implementation follows the current spec text more closely.

But also include the fix from <tc39/ecma262#3404>.

Differential Revision: https://phabricator.services.mozilla.com/D220231
ErichDonGubler pushed a commit to erichdongubler-mozilla/firefox that referenced this pull request Aug 28, 2024
…spidermonkey-reviewers,jandem

`ValidateAndApplyPropertyDescriptor` was refactored in <tc39/ecma262#2468>,
make sure our implementation follows the current spec text more closely.

But also include the fix from <tc39/ecma262#3404>.

Differential Revision: https://phabricator.services.mozilla.com/D220231
@bakkot bakkot added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Oct 23, 2024
ljharb and others added 2 commits October 23, 2024 15:48
If an implementation can produce distinguishable NaN values, then
writing NaN values to a frozen (non-configurable and non-writable)
property can be detectable.
@ljharb ljharb merged commit 54e795f into tc39:main Oct 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants