Skip to content

Polyfill: Replace unreachable overshoot block with assertion in calendarToIsoDate - #3292

Merged
ptomato merged 3 commits into
tc39:mainfrom
jessealama:calendarToIsoDate-overshoot-dead-code
Mar 5, 2026
Merged

Polyfill: Replace unreachable overshoot block with assertion in calendarToIsoDate#3292
ptomato merged 3 commits into
tc39:mainfrom
jessealama:calendarToIsoDate-overshoot-dead-code

Conversation

@jessealama

@jessealama jessealama commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator

The overshoot block in calendarToIsoDate's binary search appears unreachable. The closest candidate is Coptic/Ethiopic month 13 (only 5–6 days), where the 8-day step could theoretically skip the month entirely — but even there, I haven't been able to construct an example that triggers it. The refinement step keeps estimates close enough that calculateSameMonthResult always handles them first.

Replace it with an assertNotReached so we get a clear error if this analysis is ever wrong.

Closes #3217

@jessealama
jessealama force-pushed the calendarToIsoDate-overshoot-dead-code branch from 0f3fa2f to b32e955 Compare March 5, 2026 14:56
@jessealama

jessealama commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

This PR is similar to #3291 in that it originates in a more aggressive trimming of dead code (#3289)

@jessealama
jessealama requested a review from ptomato March 5, 2026 15:01
@codecov

codecov Bot commented Mar 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (13f6fab) to head (faf750a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3292      +/-   ##
==========================================
+ Coverage   97.64%   97.83%   +0.19%     
==========================================
  Files          22       22              
  Lines       10746    10725      -21     
  Branches     1855     1856       +1     
==========================================
  Hits        10493    10493              
+ Misses        235      215      -20     
+ Partials       18       17       -1     

☔ 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.

@jessealama
jessealama force-pushed the calendarToIsoDate-overshoot-dead-code branch from b32e955 to 5c419c3 Compare March 5, 2026 15:01

@ptomato ptomato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for doing the extra research to try to find a case that would reach this code. I was a bit uneasy removing this because it may have been put there for a reason that's lost to the mists of time (this generic calendar implementation was done in a hurry)

On the other hand, since it corresponds to the implementation-defined part of the spec text, there isn't that much potential downside to removing it, as you point out.

I think the assertNotReached can be simplified into an assert so we don't have to mess around with c8 magic comments, but I'll fix that up before merging.

Thanks!

@ptomato
ptomato force-pushed the calendarToIsoDate-overshoot-dead-code branch from 5c419c3 to 501d4ae Compare March 5, 2026 20:15
@ptomato

ptomato commented Mar 5, 2026

Copy link
Copy Markdown
Member

We should fix up the comment as well, since it's no longer a binary search.

@ptomato
ptomato merged commit 17d7ff1 into tc39:main Mar 5, 2026
10 checks passed
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.

Polyfill: Coverage gap in calendarToIsoDate

2 participants