1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:27:45 +00:00

LibJS: Fix numeric type confusion in ToTemporalRoundingIncrement

This is an editorial change in the Temporal spec.

See: 6e59366
This commit is contained in:
Linus Groh 2022-03-10 17:22:15 +01:00
parent 4ceff91893
commit 34371b9b61

View file

@ -298,31 +298,31 @@ ThrowCompletionOr<u64> to_temporal_rounding_increment(GlobalObject& global_objec
double maximum; double maximum;
// 1. If dividend is undefined, then // 1. If dividend is undefined, then
if (!dividend.has_value()) { if (!dividend.has_value()) {
// a. Let maximum be +∞. // a. Let maximum be +∞𝔽.
maximum = INFINITY; maximum = INFINITY;
} }
// 2. Else if inclusive is true, then // 2. Else if inclusive is true, then
else if (inclusive) { else if (inclusive) {
// a. Let maximum be dividend. // a. Let maximum be 𝔽(dividend).
maximum = *dividend; maximum = *dividend;
} }
// 3. Else if dividend is more than 1, then // 3. Else if dividend is more than 1, then
else if (*dividend > 1) { else if (*dividend > 1) {
// a. Let maximum be dividend 1. // a. Let maximum be 𝔽(dividend 1).
maximum = *dividend - 1; maximum = *dividend - 1;
} }
// 4. Else, // 4. Else,
else { else {
// a. Let maximum be 1. // a. Let maximum be 1𝔽.
maximum = 1; maximum = 1;
} }
// 5. Let increment be ? GetOption(normalizedOptions, "roundingIncrement", « Number », empty, 1). // 5. Let increment be ? GetOption(normalizedOptions, "roundingIncrement", « Number », empty, 1𝔽).
auto increment_value = TRY(get_option(global_object, normalized_options, vm.names.roundingIncrement, { OptionType::Number }, {}, Value(1))); auto increment_value = TRY(get_option(global_object, normalized_options, vm.names.roundingIncrement, { OptionType::Number }, {}, Value(1)));
VERIFY(increment_value.is_number()); VERIFY(increment_value.is_number());
auto increment = increment_value.as_double(); auto increment = increment_value.as_double();
// 6. If increment < 1 or increment > maximum, throw a RangeError exception. // 6. If increment < 1𝔽 or increment > maximum, throw a RangeError exception.
if (increment < 1 || increment > maximum) if (increment < 1 || increment > maximum)
return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, increment, "roundingIncrement"); return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, increment, "roundingIncrement");