1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

LibJS: Check for invalid epoch nanoseconds in getPossibleInstantsFor()

This is a normative change in the Temporal spec.

See: 439e6af
This commit is contained in:
Linus Groh 2022-06-23 19:46:27 +01:00
parent 61bdbe712e
commit d10e0f0e3e

View file

@ -157,10 +157,14 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for)
// 7. For each value epochNanoseconds in possibleEpochNanoseconds, do
for (auto& epoch_nanoseconds : possible_epoch_nanoseconds) {
// a. Let instant be ! CreateTemporalInstant(epochNanoseconds).
// a. If ! IsValidEpochNanoseconds(epochNanoseconds) is false, throw a RangeError exception.
if (!is_valid_epoch_nanoseconds(*epoch_nanoseconds))
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
// b. Let instant be ! CreateTemporalInstant(epochNanoseconds).
auto* instant = MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
// b. Append instant to possibleInstants.
// c. Append instant to possibleInstants.
possible_instants.append(instant);
}