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: Remove unnecessary checks for undefined before ToPositiveInteger #2332

Merged
merged 2 commits into from
Jun 30, 2022

Conversation

anba
Copy link
Contributor

@anba anba commented Jun 27, 2022

ToPositiveInteger(undefined) calls ToIntegerThrowOnInfinity(undefined), which in turn calls ToIntegerOrInfinity(undefined), which in turn calls ToNumber(undefined). ToNumber returns NaN, ToIntegerOrInfinity then returns 0, ToIntegerThrowOnInfinity returns 0 unchanged, and finally ToPositiveInteger will throw a RangeError for 0. That means it's not necessary to handle undefined before calling ToPositiveInteger.


Split from #2265.

…nteger

`ToPositiveInteger(undefined)` calls
`ToIntegerThrowOnInfinity(undefined)`, which in turn calls
`ToIntegerOrInfinity(undefined)`, which in turn calls
`ToNumber(undefined)`. `ToNumber` returns `NaN`, `ToIntegerOrInfinity`
then returns `0`, `ToIntegerThrowOnInfinity` returns `0` unchanged, and
finally `ToPositiveInteger` will throw a RangeError for `0`. That means
it's not necessary to handle `undefined` before calling
`ToPositiveInteger`.
@codecov
Copy link

codecov bot commented Jun 27, 2022

Codecov Report

Merging #2332 (019c4e9) into main (b79ab43) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #2332   +/-   ##
=======================================
  Coverage   91.09%   91.09%           
=======================================
  Files          19       19           
  Lines       10579    10579           
  Branches     1696     1696           
=======================================
  Hits         9637     9637           
  Misses        932      932           
  Partials       10       10           
Flag Coverage Δ
test262 84.01% <ø> (ø)
tests 81.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b79ab43...019c4e9. Read the comment docs.

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

Thanks!

@ptomato ptomato merged commit 29cd94b into tc39:main Jun 30, 2022
@anba anba deleted the validate-undef-pos-integer branch August 4, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants