Skip to content

Commit

Permalink
Editorial: Make CreateTemporalDate fallible in a few places
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ptomato committed Oct 11, 2023
1 parent 3b507f0 commit 9356ea8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ <h1>
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_).
Expand Down
2 changes: 1 addition & 1 deletion spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ <h1>
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_).
Expand Down

0 comments on commit 9356ea8

Please sign in to comment.