Polyfill: Replace unreachable retry with assertion in NudgeToCalendarUnit#3291
Polyfill: Replace unreachable retry with assertion in NudgeToCalendarUnit#3291jessealama wants to merge 1 commit intotc39:mainfrom
Conversation
…Unit The retry path for negative durations appears unreachable: end-of-month constraining reduces the day, which for negative durations pushes the endpoint further from the origin, so the nudge window always contains the destination. Closes tc39#3235
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3291 +/- ##
==========================================
+ Coverage 97.40% 97.57% +0.16%
==========================================
Files 22 22
Lines 10771 10757 -14
Branches 1866 1865 -1
==========================================
+ Hits 10492 10496 +4
+ Misses 258 240 -18
Partials 21 21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This change was originally in #3289 (where it was simply deleted, without even an assertion in place). |
|
I think if we assume this code can't be reached by any JS code, we should change the spec text accordingly to have an assertion there as well, and submit it as an editorial change. (Could possibly also be done after stage 4.) I have a hunch that the reason the nudge window only needs to be retried when moving forwards, is because the reason for the retry is when the edge of the window lands in a DST gap. The |
The retry path for negative durations appears unreachable: end-of-month constraining reduces the day, which for negative durations pushes the endpoint further from the origin, so the nudge window always contains the destination.
This isn't a rigorous proof of unreachability, but we haven't been able to construct a test case that exercises this path. Replace the retry block with an assertion guarding the invariant, so that if we're wrong, we'll get a clear error rather than silent misbehavior.
Closes #3235