-
Notifications
You must be signed in to change notification settings - Fork 150
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
Editorial: Add missing checks before calling ApplyUnsignedRoundingMode #2884
Conversation
Instead of checking |
Hmm, it looks like 9be3190 needs more checks to guarantee that |
ApplyUnsignedRoundingMode requires `r1 ≤ t < r2`, see step 2. Add missing checks to ensure this requirement is fulfilled when called from NudgeToCalendarUnit. Drive-by change: Update RoundNumberToIncrement to call GetUnsignedRoundingMode with correct spec type. Also fixes tc39#2893.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks.
I think without custom calendars, the RangeErrors may be changed to assertions, but I'll merge this first and update that if necessary when merging the PR removing custom calendars.
Implements the extra checks and assertions from the previous commit, as well as the use of abs() to simplify the didExpandCalendarUnit check and to satisfy the requirements of ApplyUnsignedRoundingMode.
I've made the corresponding changes in the reference code as well, to exercise them on the test262 suite. |
This reverts a line from tc39#2884 that changed an exception to an assertion. The assertion can actually be hit, so change it back.
Changes:
abs
for all arguments passed toApplyUnsignedRoundingMode
to ensure ther1 ≤ x < r2
requirement inApplyUnsignedRoundingMode
is fulfilled.startEpochNs
andendEpochNs
are now required to be correctly ordered. This ensures thatprogress
is a proper fraction. (If it's not a proper fraction, thenabs(total)
can be larger thanabs(r2)
, which is invalid forApplyUnsignedRoundingMode
.)roundedUnit
againstabs(r2)
.