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: Move GetOptionsObject closer to the top #2721

Closed
anba opened this issue Nov 6, 2023 · 8 comments
Assignees
Labels
editorial spec-text Specification text involved
Milestone

Comments

@anba
Copy link
Contributor

anba commented Nov 6, 2023

AddDurationToOrSubtractDurationFromPlainYearMonth should probably call GetOptionsObject earlier to validate the user-supplied input before performing other user-visible operations. Maybe move it directly before the BalanceTimeDuration call in step 3?

@ptomato
Copy link
Collaborator

ptomato commented Nov 6, 2023

This ordering was intentional — the design principle followed here is, perform validation on each argument in order (temporalDurationLike, then options). So, personally I'd prefer not changing anything here, especially as we are trying to keep changes as rare as possible this late in stage 3, but we can discuss it in the next champions meeting.

@anba
Copy link
Contributor Author

anba commented Nov 6, 2023

I wouldn't count performing CalendarFields, PrepareTemporalFields, CalendarDateFromFields, etc. as part of the arguments validation of temporalDurationLike, though. And all these steps happen before GetOptionsObject is called.

@ptomato
Copy link
Collaborator

ptomato commented Nov 9, 2023

We discussed this in the Temporal champions meeting today (2023-11-09). Whether this adheres to the design guideline of processing each argument in order, is debatable. (We are a bit vague in the design guideline about what exactly is included in "argument processing".) But we don't see a compelling motivation to change it this late in stage 3 just for consistency unless there were a demonstration of how this causes a real problem, or how it is gratuitously different from the rest of Temporal.

(To the best of our knowledge, the only difference for end users is in the exception that might get thrown if one of the steps fails.)

@ptomato ptomato closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2023
@anba
Copy link
Contributor Author

anba commented Nov 20, 2023

I don't think "stage 3" is a valid argument for dismissing this issue, because the relevant algorithm was changed only recently (573de94). Before that commit, GetOptionsObject was called directly after BalanceTimeDuration. Looking through the commit history:

Because #2670 is actually a normative change, but was incorrectly marked as editorial, I think it's okay to add a another editorial change to revert the AddDurationToOrSubtractDurationFromPlainYearMonth changes from #2670 and instead remove the second call to GetOptionsObject. Then everything can still be marked as editorial and no normative changes are necessary.

@ptomato
Copy link
Collaborator

ptomato commented Nov 20, 2023

Thanks, that is a compelling reason to me. If a normative change was incorrectly landed as editorial, then we should revert it.

@ptomato ptomato reopened this Nov 20, 2023
@ptomato ptomato self-assigned this Nov 20, 2023
@ptomato ptomato added spec-text Specification text involved editorial and removed meeting-agenda labels Nov 20, 2023
@ptomato ptomato added this to the Stage "3.5" milestone Nov 20, 2023
@ptomato
Copy link
Collaborator

ptomato commented Nov 20, 2023

Note, to revert to the previous observable behaviour, GetOptionsObject would end up as step 4, directly after BalanceTimeDuration, not directly before it.

@ptomato
Copy link
Collaborator

ptomato commented Nov 20, 2023

(Which is fine with me, personally. I think BalanceTimeDuration is arguably validation of the duration argument to add/subtract, which comes before options.)

@anba
Copy link
Contributor Author

anba commented Nov 21, 2023

This is also fine with me, because BalanceTimeDuration can't trigger any user-controlled code, so the only difference is which error is thrown (RangeError from BalanceTimeDuration or TypeError from GetOptionsObject). But it seems with #2727 applied, BalanceTimeDuration can no longer thrown an error, so it doesn't actually matter if GetOptionsObject is called before or after an infallible BalanceTimeDuration.

ptomato added a commit that referenced this issue Dec 13, 2023
05f7a11 (part of #2670)
inadvertently made an observable change. This restores the previous
observable semantics.

Thanks to Anba for spotting this.

Closes: #2721
guijemont added a commit to guijemont/proposal-temporal that referenced this issue Jan 3, 2024
…tOptionsObject closer to top

PR tc39#2670 accidentally introduced a normative change by removing the
early call to GetOptionsObject. This effectively revert this part of the
change, and instead removes the later GetOptionsObject call which is
redundant.

Closes: tc39#2721
@Ms2ger Ms2ger closed this as completed in 0cd94eb Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial spec-text Specification text involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants