1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:08:12 +00:00

LibJS: Use narrower types in Temporal PlainDate/PlainDateTime/Calendar

These are bounds-checked during construction of PlainDate/PlainDateTime
and as such theres no need to widen them in these internal AO calls.
This commit is contained in:
Idan Horowitz 2021-07-26 16:48:47 +03:00 committed by Linus Groh
parent c5c32ad274
commit 2c6bd3a61b
11 changed files with 47 additions and 49 deletions

View file

@ -84,7 +84,7 @@ Value PlainDateConstructor::construct(FunctionObject& new_target)
// IMPLEMENTATION DEFINED: This is an optimization that allows us to treat these doubles as normal integers from this point onwards.
// This does not change the exposed behaviour as the call to CreateTemporalDate will immediately check that these values are valid
// ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check.
if (!AK::is_within_range<i32>(y) || !AK::is_within_range<i32>(m) || !AK::is_within_range<i32>(d)) {
if (!AK::is_within_range<i32>(y) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(d)) {
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate);
return {};
}