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

AddDurationToOrSubtractDurationFromPlainYearMonth: CreateTemporalDate is fallible #2700

Closed
anba opened this issue Oct 10, 2023 · 1 comment
Closed
Assignees

Comments

@anba
Copy link
Contributor

anba commented Oct 10, 2023

AddDurationToOrSubtractDurationFromPlainYearMonth, step 12.d:

Let endOfMonth be ! CreateTemporalDate(endOfMonthISO.[[Year]], endOfMonthISO.[[Month]], endOfMonthISO.[[Day]], calendar).

But CreateTemporalDate is fallible. Test case:

let cal = new class extends Temporal.Calendar {
  dateAdd(date, duration, options) {
    return new Temporal.PlainDate(-271821, 4, 19);
  }
}("iso8601");

let pym = new Temporal.PlainYearMonth(2000, 1, cal);

let d = Temporal.Duration.from({
  days: -1,
});

pym.add(d);
@ptomato ptomato self-assigned this Oct 11, 2023
@ptomato
Copy link
Collaborator

ptomato commented Oct 11, 2023

Thanks! I concur.

ptomato added a commit that referenced this issue Oct 11, 2023
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
ptomato added a commit to ptomato/test262 that referenced this issue Oct 11, 2023
In PlainYearMonth arithmetic, we need to find the end of the month when
adding a negative duration or subtracting a positive one. This end of the
month can be out of range.

Test case based on one provided by Anba. See issue:
tc39/proposal-temporal#2700
ptomato added a commit to ptomato/test262 that referenced this issue Oct 12, 2023
In PlainYearMonth arithmetic, we need to find the end of the month when
adding a negative duration or subtracting a positive one. This end of the
month can be out of range.

Test case based on one provided by Anba. See issue:
tc39/proposal-temporal#2700
@Ms2ger Ms2ger closed this as completed in d1cd4e1 Oct 12, 2023
ptomato added a commit to ptomato/test262 that referenced this issue Oct 18, 2023
In PlainYearMonth arithmetic, we need to find the end of the month when
adding a negative duration or subtracting a positive one. This end of the
month can be out of range.

Test case based on one provided by Anba. See issue:
tc39/proposal-temporal#2700
ptomato added a commit to tc39/test262 that referenced this issue Oct 18, 2023
In PlainYearMonth arithmetic, we need to find the end of the month when
adding a negative duration or subtracting a positive one. This end of the
month can be out of range.

Test case based on one provided by Anba. See issue:
tc39/proposal-temporal#2700
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

No branches or pull requests

2 participants