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: Update range comparisons involving a zero #3523

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

gibson042
Copy link
Contributor

  • When zero bounds a Number range, always use < -0𝔽 or > +0𝔽 (there was one exception).
  • Consolidate static bounds checking in IsValidIntegerIndex and StringGetOwnProperty (index Numbers with negative sign bit are in the same "not applicable" category as non-integers).
  • Clean up StringGetOwnProperty to remove a redundant check and swap comparison operands for a more conventional ordering.

1. Let _taRecord_ be MakeTypedArrayWithBufferWitnessRecord(_O_, ~unordered~).
1. NOTE: Bounds checking is not a synchronizing operation when _O_'s backing buffer is a growable SharedArrayBuffer.
1. If IsTypedArrayOutOfBounds(_taRecord_) is *true*, return *false*.
1. Let _length_ be TypedArrayLength(_taRecord_).
1. If ℝ(_index_) &lt; 0 or ℝ(_index_) ≥ _length_, return *false*.
1. If ℝ(_index_) ≥ _length_, return *false*.
Copy link
Contributor

Choose a reason for hiding this comment

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

I am pretty sure this is indeed editorial, but I'd like @syg to confirm. (Specifically, this change means that passing -1 will now skip the MakeTypedArrayWithBufferWitnessRecord step, but per the note about bounds checking not being a synchronizing operation I think that's not observable.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think because it's unordered it is fine.

Copy link
Contributor

@bakkot bakkot left a comment

Choose a reason for hiding this comment

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

LGTM pending approval from Shu for the TA change. The esmeta failures can be fixed by removing TypedArrayGetElement and TypedArraySetElement from esmeta-ignore.json, per the CI logs, which we can do when merging if you don't get there first.

@michaelficarra michaelficarra added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Jan 16, 2025
…and StringGetOwnProperty (tc39#3523)

Index Numbers with negative sign bit are in the same "not applicable" category as non-integers.
Remove a redundant check and swap comparison operands for a more conventional ordering.
@ljharb ljharb force-pushed the 2025-01-negative-zero-comparisons branch from 060a90e to f2eff8d Compare January 16, 2025 17:10
@ljharb ljharb merged commit f2eff8d into tc39:main Jan 16, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change 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.

5 participants