Skip to content

Polyfill: Change check to assertion in adjustCalendarDate#3221

Closed
catamorphism wants to merge 1 commit intotc39:mainfrom
catamorphism:adjustCalendarDate-check
Closed

Polyfill: Change check to assertion in adjustCalendarDate#3221
catamorphism wants to merge 1 commit intotc39:mainfrom
catamorphism:adjustCalendarDate-check

Conversation

@catamorphism
Copy link
Copy Markdown
Contributor

This should be guaranteed by the previous call to validateCalendarDate.

This should be guaranteed by the previous call to validateCalendarDate.
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 19, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3221   +/-   ##
=======================================
  Coverage   96.75%   96.76%           
=======================================
  Files          22       22           
  Lines       10398    10399    +1     
  Branches     1859     1858    -1     
=======================================
+ Hits        10061    10063    +2     
+ Misses        289      288    -1     
  Partials       48       48           

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

Should probably gain a test262 test instead.

Comment thread polyfill/lib/calendar.mjs
const largestMonth = this.monthsInYear({ year });
if (month < 1 || month > largestMonth) throw new RangeErrorCtor(`Invalid monthCode: ${monthCode}`);
// The earlier call to validateCalendarDate guarantees this.
assert(month >= 1 && month <= largestMonth, `invalid monthCode: ${monthCode}`);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This isn't quite the same as what's guaranteed in validateCalendarDate. I see there that the number part of the month code is validated to be between 1 and 13 inclusive, but in a 12-month year I can trigger this assertion:

Temporal.PlainDate.from({ calendar: 'hebrew', year: 5781, monthCode: 'M13', day: 1 })

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. There's already a test262 test: https://github.com/tc39/test262/blob/main/test/intl402/Temporal/PlainDate/from/invalid-month-codes-hebrew.js

and I see that codecov.io shows this line as green now (not sure why it was red before, as that test was added in Nov. 2025), so I think I can just close this PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably it was red because 5781 is a common year and 5779 is a leap year, which happen to be different code paths. So it still might be worth adding a line to that test file. (I'm not sure why the line is green now.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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