Skip to content

Conversation

@catamorphism
Copy link
Contributor

This check should be an assertion, as the condition is checked before calling untilCalendar.

This check should be an assertion, as the condition is checked
before calling untilCalendar.
@catamorphism catamorphism force-pushed the remove-check-untilCalendar branch from b380ac7 to 91056e5 Compare December 19, 2025 20:34
@catamorphism catamorphism changed the title Polyfill: Change check to assertion in untiLCalendar Polyfill: Change check to assertion in untilCalendar Dec 19, 2025
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.41%. Comparing base (03f9057) to head (c534e88).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3218      +/-   ##
==========================================
+ Coverage   96.75%   97.41%   +0.65%     
==========================================
  Files          22       22              
  Lines       10398    10399       +1     
  Branches     1859     1826      -33     
==========================================
+ Hits        10061    10130      +69     
+ Misses        289      245      -44     
+ Partials       48       24      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a code snippet that triggers this assertion:

const d1 = Temporal.PlainDateTime.from('2026-01-06T11:02[u-ca=gregory]');
const d2 = Temporal.PlainDateTime.from('2026-01-07T09:02[u-ca=gregory]');
d1.until(d2, { largestUnit: 'years' });

So probably we should consider it a testing coverage gap in any case.

I guess to fix this, we should decide at what level we want to have this early return. As long as it isn't observable, we can do this editorially.

One possibility is to fix all callers of CalendarDateUntil both in the polyfill and spec text so that we can make the assertion in CalendarDateUntil. Another possibility is to just make CalendarDateUntil definitively return if the two dates are equal and then we can make the assertion here in nonISOHelperBase.untilCalendar.

@catamorphism
Copy link
Contributor Author

One possibility is to fix all callers of CalendarDateUntil both in the polyfill and spec text so that we can make the assertion in CalendarDateUntil. Another possibility is to just make CalendarDateUntil definitively return if the two dates are equal and then we can make the assertion here in nonISOHelperBase.untilCalendar.

@ptomato I added the early return in CalendarDateUntil; that seems like the simplest thing. I'll also submit a test262 PR with your test.

@catamorphism
Copy link
Contributor Author

test262 PR: tc39/test262#4813

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

Successfully merging this pull request may close these issues.

2 participants