1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:58:11 +00:00

LibJS: Remove assertions that are now part of structured headers

This is an editorial change in the Temporal spec.

See:
- 7fbdd28
- f666243
- 8c7d066
- 307d108
- d9ca402

In practical terms this means we can now get rid of a couple of awkward
assertion steps that were no-ops anyway, since the types are enforced
by the compiler.
This commit is contained in:
Linus Groh 2022-03-09 23:51:53 +01:00
parent 97bd4cebab
commit 64e43c89bc
5 changed files with 86 additions and 106 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
* Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
@ -151,10 +151,9 @@ ThrowCompletionOr<BigInt*> add_instant(GlobalObject& global_object, BigInt const
{
auto& vm = global_object.vm();
// 1. Assert: hours, minutes, seconds, milliseconds, microseconds, and nanoseconds are integer Number values.
VERIFY(hours == trunc(hours) && minutes == trunc(minutes) && seconds == trunc(seconds) && milliseconds == trunc(milliseconds) && microseconds == trunc(microseconds) && nanoseconds == trunc(nanoseconds));
// 2. Let result be epochNanoseconds + (nanoseconds) + (microseconds) × 1000 + (milliseconds) × 10^6 + (seconds) × 10^9 + (minutes) × 60 × 10^9 + (hours) × 3600 × 10^9.
// 1. Let result be epochNanoseconds + (nanoseconds) + (microseconds) × 1000 + (milliseconds) × 10^6 + (seconds) × 10^9 + (minutes) × 60 × 10^9 + (hours) × 3600 × 10^9.
// FIXME: Pretty sure i64's are not sufficient for the extreme cases.
auto* result = js_bigint(vm,
epoch_nanoseconds.big_integer()
@ -165,11 +164,11 @@ ThrowCompletionOr<BigInt*> add_instant(GlobalObject& global_object, BigInt const
.plus(Crypto::SignedBigInteger::create_from((i64)minutes).multiplied_by(Crypto::SignedBigInteger { 60 }).multiplied_by(Crypto::SignedBigInteger { 1'000'000'000 }))
.plus(Crypto::SignedBigInteger::create_from((i64)hours).multiplied_by(Crypto::SignedBigInteger { 3600 }).multiplied_by(Crypto::SignedBigInteger { 1'000'000'000 })));
// If ! IsValidEpochNanoseconds(result) is false, throw a RangeError exception.
// 2. If ! IsValidEpochNanoseconds(result) is false, throw a RangeError exception.
if (!is_valid_epoch_nanoseconds(*result))
return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds);
// 4. Return result.
// 3. Return result.
return result;
}