-
Notifications
You must be signed in to change notification settings - Fork 238
Description
Related: #7076
See fuzz results in #7206
Trying to add DateDuration { is_negative: false, years: 4294901760, months: 256, weeks: 0, days: 0} to Dangi date 0-1-1 produces a panic at
icu4x/components/calendar/src/duration.rs
Line 244 in 1fbff08
| debug_assert!(false, "{year} + {self:?} out of year range"); |
{months: 1281, days: 8589934592} does not produce a panic but produces a very slow result (#7077 for optimizations). When we first tested this I verified that no arithmetic operation within Temporal range was slow, but I did not verify this outside of the Temporal range; thinking Temporal would filter these out. It doesn't: Temporal allows for a much wider range of Durations than needed, only erroring if the final result is out of range. This somewhat makes sense, in theory you could have a calendar where each day is a year so adding a large number of years might still keep you in range.
In #7065 we got to the point where we support dates in the range of all i32 year values for a given calendar. We need to make a similar determination for durations: when do we error for duration arithmetic being out of range?
The easy thing to do is ensure that these debug assertions in duration.rs turn into errors, which might fix most issues. I'm not sure it will fix the slow code, we might want to preemptively error when we know something will be out of range.