From c2b0b69f2fa15a2cdd2677ba6b49dd8fd0abd765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 9 Jun 2022 11:12:01 +0200 Subject: [PATCH 1/2] Editorial: Remove unnecessary checks for undefined before ToPositiveInteger `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`. --- spec/calendar.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/calendar.html b/spec/calendar.html index bdbff323a5..f35cdeac21 100644 --- a/spec/calendar.html +++ b/spec/calendar.html @@ -166,7 +166,6 @@

CalendarMonth ( _calendar_, _dateLike_ )

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_). @@ -192,7 +191,6 @@

CalendarDay ( _calendar_, _dateLike_ )

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_). From 019c4e9bf415d7edd8f4180dcfc75eac20dd4454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Mon, 27 Jun 2022 16:55:43 +0200 Subject: [PATCH 2/2] Editorial: Add a note that ToPositiveInteger(undefined) throws --- spec/calendar.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/calendar.html b/spec/calendar.html index f35cdeac21..4b1ffbbc91 100644 --- a/spec/calendar.html +++ b/spec/calendar.html @@ -168,6 +168,7 @@

CalendarMonth ( _calendar_, _dateLike_ )

1. Let _result_ be ? Invoke(_calendar_, *"month"*, « _dateLike_ »). 1. Return ? ToPositiveInteger(_result_). + ToPositiveInteger(*undefined*) will throw a *RangeError*. @@ -193,6 +194,7 @@

CalendarDay ( _calendar_, _dateLike_ )

1. Let _result_ be ? Invoke(_calendar_, *"day"*, « _dateLike_ »). 1. Return ? ToPositiveInteger(_result_). + ToPositiveInteger(*undefined*) will throw a *RangeError*.