-
Notifications
You must be signed in to change notification settings - Fork 31
Update to new ComputeNudgeWindow spec text #636
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
Conversation
d3594c8 to
9a445cb
Compare
|
This now passes tests, but I'm not entirely sure of the impl |
9a445cb to
6394a10
Compare
|
This fails other tests (due to hitting assertions, I think) |
nekevss
left a comment
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.
Have a couple notes after taking a glance.
Are you still looking into the failures mentioned above?
No, but they should be replicable by copying the tests. |
6394a10 to
acb80b0
Compare
|
The failures were due to a missing <=. Fixed. |
|
And that fixes the crashes. Would still like to see if this can be written without floats, but I don't have time to do that myself. |
acb80b0 to
80b79a3
Compare
|
Note: I'm not actively working on this right now, and don't really plan to in the near future, if someone wants to figure out how to make the float stuff work. |
|
I have some time and can take a look at this now if you're not currently working on it. |
|
That would be great! |
| // TODO: Add unit tests specifically for nudge_calendar_unit if possible. | ||
| fn nudge_calendar_unit( | ||
|
|
||
| fn nudge_calendar_unit_total( |
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.
nit: mention what spec item this is and why it is different
question: why is this different?
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.
If you look at the specification, the return of NudgeToCalendarUnit is a record of (NudgeRecord, Total).
The callers of NudgeToCalendarUnit are RoundRelativeDuration and TotalRelativeDuration, the return type of NudgeRecord and Total correspond with the callers, respectively.
This means that for TotalRelativeDuration, the NudgeRecord is being computed and directly discarded; meanwhile, for RoundRelativeDuration, the value of total must be a f64, because the return type of total is a f64.
Ultimately, the changes separate these out into different codepaths, and therefore we are only computing exactly what we need for round and total
| /// <https://tc39.es/proposal-temporal/#sec-temporal-computenudgewindow> | ||
| /// `compute_nudge_window` in `temporal_rs` refers to step 1-12 of `NudgeToCalendarUnit`. | ||
| /// | ||
| /// For A.O. `ComputeNudgeWinodw`, see `compute_nudge_window_with_shift` |
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.
issue: this is confusing, let's call this compute_and_adjust_nudge_window or something
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.
That's fair. I can go with that.
|
Running this code patched into v8 gives me two (expected) new test successes and one new test failure in |
Shoot, confirmed in Boa too. This looks like it may have something to do with f1c2828. But the curious thing is that that fixed the new precision calculations ... EDIT: Oh, we need to do the full precision calculation. |
|
All tests pass locally on Boa for Duration. |
|
Also V8 |
Manishearth
left a comment
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.
r+
Uplift of boa-dev/temporal#647, boa-dev/temporal#636, unicode-org/icu4x#7321 Change-Id: Icf703e2ae907a6a820b6b1141883ed9ab825874c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7261567 Commit-Queue: Manish Goregaokar <manishearth@google.com> Auto-Submit: Manish Goregaokar <manishearth@google.com> Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Commit-Position: refs/heads/main@{#1559085}
Fixes #635
Updates to tc39/proposal-temporal#3172
This passes the test, but it fails other tests. The problem is probably that IncrementRounder isn't written in terms of r1 and r2. @nekevss, I don't understand the full purpose of IncrementRounder being written the way it is: mind having a look?The new spec text changes how r1 and r2 are computed, and they're passed down to IncrementRounder in the spec but not the code, so I assume that IncrementRounder is recomputing them somehow from the inputs.I wrote this to not use IncrementRounder. I'm not 100% sure if the implementation is correct when it comes to how it handles mathematical values.