LibJS: Migrate ToIntegerIfIntegral to ECMA-262

This is an editorial change in the Temporal proposal. See:
5f76109
This commit is contained in:
Timothy Flynn 2025-02-28 12:22:27 -05:00 committed by Andreas Kling
commit aa737bb654
Notes: github-actions[bot] 2025-03-01 13:50:37 +00:00
3 changed files with 16 additions and 16 deletions

View file

@ -243,19 +243,4 @@ ThrowCompletionOr<double> to_positive_integer_with_truncation(VM& vm, Value argu
return integer;
}
// 13.39 ToIntegerIfIntegral ( argument ), https://tc39.es/proposal-temporal/#sec-tointegerifintegral
template<typename... Args>
ThrowCompletionOr<double> to_integer_if_integral(VM& vm, Value argument, ErrorType error_type, Args&&... args)
{
// 1. Let number be ? ToNumber(argument).
auto number = TRY(argument.to_number(vm));
// 2. If number is not an integral Number, throw a RangeError exception.
if (!number.is_integral_number())
return vm.throw_completion<RangeError>(error_type, forward<Args>(args)...);
// 3. Return (number).
return number.as_double();
}
}