From 9356ea8a0852c5a3041a2b94ef67dbcfa9d44ea3 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Tue, 10 Oct 2023 17:19:35 -0700 Subject: [PATCH] Editorial: Make CreateTemporalDate fallible in a few places The AddISODate call in the previous lines may return a result record that is out of range and cannot successfully be passed to CreateTemporalDate, and so this step should be fallible. Thanks to Anba for spotting this. Closes: #2697 Closes: #2700 --- spec/duration.html | 2 +- spec/plainyearmonth.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/duration.html b/spec/duration.html index 4b432b4e49..c5e40a3632 100644 --- a/spec/duration.html +++ b/spec/duration.html @@ -1774,7 +1774,7 @@

1. Set _plainRelativeTo_ to _yearsLater_. 1. Set _fractionalDays_ to _fractionalDays_ + _monthsWeeksInDays_. 1. Let _isoResult_ be ! AddISODate(_plainRelativeTo_.[[ISOYear]]. _plainRelativeTo_.[[ISOMonth]], _plainRelativeTo_.[[ISODay]], 0, 0, 0, truncate(_fractionalDays_), *"constrain"*). - 1. Let _wholeDaysLater_ be ! CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). + 1. Let _wholeDaysLater_ be ? CreateTemporalDate(_isoResult_.[[Year]], _isoResult_.[[Month]], _isoResult_.[[Day]], _calendar_). 1. Let _untilOptions_ be OrdinaryObjectCreate(*null*). 1. Perform ! CreateDataPropertyOrThrow(_untilOptions_, *"largestUnit"*, *"year"*). 1. Let _timePassed_ be ? DifferenceDate(_calendar_, _plainRelativeTo_, _wholeDaysLater_, _untilOptions_). diff --git a/spec/plainyearmonth.html b/spec/plainyearmonth.html index 58c3e6f382..154955fd12 100644 --- a/spec/plainyearmonth.html +++ b/spec/plainyearmonth.html @@ -683,7 +683,7 @@

1. Let _oneMonthDuration_ be ! CreateTemporalDuration(0, 1, 0, 0, 0, 0, 0, 0, 0, 0). 1. Let _nextMonth_ be ? CalendarDateAdd(_calendar_, _intermediateDate_, _oneMonthDuration_, *undefined*, _dateAdd_). 1. Let _endOfMonthISO_ be ! AddISODate(_nextMonth_.[[ISOYear]], _nextMonth_.[[ISOMonth]], _nextMonth_.[[ISODay]], 0, 0, 0, -1, *"constrain"*). - 1. Let _endOfMonth_ be ! CreateTemporalDate(_endOfMonthISO_.[[Year]], _endOfMonthISO_.[[Month]], _endOfMonthISO_.[[Day]], _calendar_). + 1. Let _endOfMonth_ be ? CreateTemporalDate(_endOfMonthISO_.[[Year]], _endOfMonthISO_.[[Month]], _endOfMonthISO_.[[Day]], _calendar_). 1. Let _day_ be ? CalendarDay(_calendar_, _endOfMonth_). 1. Perform ! CreateDataPropertyOrThrow(_fieldsCopy_, *"day"*, _day_). 1. Let _date_ be ? CalendarDateFromFields(_calendar_, _fieldsCopy_).