mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:47:34 +00:00
LibJS: Throw RangeError for non-integral values in ToPartialDuration
This is a normative change in the Temporal spec.
See: 895c8e5
This commit is contained in:
parent
7acd174c85
commit
0e6d503317
2 changed files with 19 additions and 7 deletions
|
@ -214,13 +214,20 @@ PartialDuration to_partial_duration(GlobalObject& global_object, Value temporal_
|
|||
// i. Set any to true.
|
||||
any = true;
|
||||
|
||||
// ii. Set value to ? ToIntegerOrInfinity(value).
|
||||
auto value_number = value.to_integer_or_infinity(global_object);
|
||||
// ii. Set value to ? ToNumber(value).
|
||||
value = value.to_number(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
|
||||
// iii. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
||||
result.*internal_slot = value_number;
|
||||
// iii. If ! IsIntegralNumber(value) is false, then
|
||||
if (!value.is_integral_number()) {
|
||||
// 1. Throw a RangeError exception.
|
||||
vm.throw_exception<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, property.as_string(), value.to_string_without_side_effects());
|
||||
return {};
|
||||
}
|
||||
|
||||
// iv. Set result's internal slot whose name is the Internal Slot value of the current row to value.
|
||||
result.*internal_slot = value.as_double();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue