Skip to content

Commit

Permalink
Editorial: Remove unnecessary checks for undefined before ToPositiveI…
Browse files Browse the repository at this point in the history
…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`.
  • Loading branch information
anba committed Jun 27, 2022
1 parent b79ab43 commit c2b0b69
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ <h1>CalendarMonth ( _calendar_, _dateLike_ )</h1>
<emu-alg>
1. Assert: Type(_calendar_) is Object.
1. Let _result_ be ? Invoke(_calendar_, *"month"*, « _dateLike_ »).
1. If _result_ is *undefined*, throw a *RangeError* exception.
1. Return ? ToPositiveInteger(_result_).
</emu-alg>
</emu-clause>
Expand All @@ -192,7 +191,6 @@ <h1>CalendarDay ( _calendar_, _dateLike_ )</h1>
<emu-alg>
1. Assert: Type(_calendar_) is Object.
1. Let _result_ be ? Invoke(_calendar_, *"day"*, « _dateLike_ »).
1. If _result_ is *undefined*, throw a *RangeError* exception.
1. Return ? ToPositiveInteger(_result_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit c2b0b69

Please sign in to comment.