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: Using is -0 instead of = -0 in StringGetOwnProperty #1963

Merged
merged 1 commit into from
May 6, 2020

Conversation

jhnaldo
Copy link
Contributor

@jhnaldo jhnaldo commented Apr 22, 2020

I revised a small part in StringGetOwnProperty to use is -0 instead of = -0 to correctly represent the semantics. The expression index = -0 denotes that index is -0 or +0 because the = operator is floating point equality operator. Thus, instead, I think that it should be revised to index is -0.

@ljharb
Copy link
Member

ljharb commented Apr 22, 2020

There's a few other cases of = 0; we should probably change all of them at once to be "is 0".

(Also, note the overlap with #1086)

@jhnaldo
Copy link
Contributor Author

jhnaldo commented Apr 24, 2020

There's a few other cases of = 0; we should probably change all of them at once to be "is 0".

(Also, note the overlap with #1086)

I'm confusing to understand the conversations in #1086.
So, in consequence, what is the exact meaning of = 0 and is 0?
I believe that the meaning is as follows:

  • x = 0 denotes x is ES Number values +0, -0, or the mathematical value 0
  • x is 0 denotes x should be mathematical value 0.

Am I right?

@ljharb
Copy link
Member

ljharb commented Apr 24, 2020

In general, there's a lot of implicitness around Number and mathematical values in the spec; this seems like it may be one of those cases.

@jhnaldo
Copy link
Contributor Author

jhnaldo commented Apr 27, 2020

@ljharb I think that = -0 and = 0 cases are slightly different. I don't know whether few cases of = 0 are correct or not, or even if they are incorrect, I don't know how to revise them.

However, I believe that the = -0 equality check in StringGetOwnProperty should revised into is -0.
According to #1752, it revised = -0 equality check to use instead is 0 and it was accepted and merged. Is there other issues that only this = -0 equality check should be considered with other cases of = 0?

Copy link
Member

@littledan littledan left a comment

Choose a reason for hiding this comment

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

This seems like a good fix to me. In the scheme of things like = relating to mathematical values, I see = -0 being the same as = 0, whereas is implies SameValue. @caiolima is working on a fixup for mathematical values in general based on discussion in #1964 ; I'd be fine with either waiting for that or landing this independently.

@michaelficarra michaelficarra added the editor call to be discussed in the next editor call label May 4, 2020
@michaelficarra michaelficarra removed the editor call to be discussed in the next editor call label May 6, 2020
@ljharb ljharb requested review from syg, ljharb, bakkot and a team May 6, 2020 22:00
@bakkot
Copy link
Contributor

bakkot commented May 6, 2020

I am in favor of this change. Specifically, for the case of comparing ECMAScript values to the ECMAScript values 0 and -0 I would prefer that we always say is +0 or is -0 rather than = 0, = +0, = -0, or is 0.

@ljharb ljharb self-assigned this May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants