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

Review MakeDay/MakeDate/TimeFromYear callers for possibly out-of-range values #2315

Closed
anba opened this issue Jun 17, 2022 · 2 comments
Closed
Assignees
Labels
normative Would be a normative change to the proposal spec-text Specification text involved
Milestone

Comments

@anba
Copy link
Contributor

anba commented Jun 17, 2022

From #1502:

MakeDate can return NaN for large year values, because MakeDay has wishy-washy definition when NaN can be returned for large values:

[...], but if this is not possible (because some argument is out of range), return NaN.

There are multiple MakeDay, MakeDate, and TimeFromYear callers which simply assert the returned value is finite, but this may not be true in practice. For example consider calling GetEpochFromISOParts with GetEpochFromISOParts(Number.MAX_VALUE, 1, 1, 0, 0, 0, 0, 0, 0).

Also see: tc39/ecma262#1087 and tc39/ecma262#1564

@ptomato ptomato added spec-text Specification text involved normative Would be a normative change to the proposal labels Jun 20, 2022
@ptomato
Copy link
Collaborator

ptomato commented Sep 8, 2022

From the duplicate #2396, this is one code sample that would have MakeDay return NaN:

var cal = new Temporal.Calendar("iso8601");
var date = new Temporal.PlainDate(1970, 1, 1);
var maxValue = new Temporal.Duration(Number.MAX_VALUE, Number.MAX_VALUE);
cal.dateAdd(date, maxValue)

This ends up calling MakeDay(𝔽(ℝ(Number.MAX_VALUE) + 1970), 0, 1) in AddISODate → BalanceISODate, and that year value is not finite.

@ptomato
Copy link
Collaborator

ptomato commented Apr 28, 2023

Closed by #2518.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative Would be a normative change to the proposal spec-text Specification text involved
Projects
None yet
Development

No branches or pull requests

3 participants