diff options
author | Linus Groh <mail@linusgroh.de> | 2022-08-16 20:33:17 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-23 13:58:30 +0100 |
commit | f3117d46dc872a2d0f57273293b5691777b06279 (patch) | |
tree | d16e8d78bfc9c94e3e6d4188f8a853a148b2b5c8 /Userland/Libraries/LibJS | |
parent | 5398dcc55e1b8279f6b3edf62ad249a27b4f2f64 (diff) | |
download | serenity-f3117d46dc872a2d0f57273293b5691777b06279.zip |
LibJS: Remove GlobalObject from VM::throw_completion()
This is a continuation of the previous five commits.
A first big step into the direction of no longer having to pass a realm
(or currently, a global object) trough layers upon layers of AOs!
Unlike the create() APIs we can safely assume that this is only ever
called when a running execution context and therefore current realm
exists. If not, you can always manually allocate the Error and put it in
a Completion :^)
In the spec, throw exceptions implicitly use the current realm's
intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
Diffstat (limited to 'Userland/Libraries/LibJS')
131 files changed, 716 insertions, 724 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index 7044063c40..901000d4dd 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -407,7 +407,6 @@ Completion NewExpression::execute(Interpreter& interpreter) const Completion CallExpression::throw_type_error_for_callee(Interpreter& interpreter, Value callee_value, StringView call_type) const { - auto& global_object = interpreter.global_object(); auto& vm = interpreter.vm(); if (is<Identifier>(*m_callee) || is<MemberExpression>(*m_callee)) { @@ -417,9 +416,9 @@ Completion CallExpression::throw_type_error_for_callee(Interpreter& interpreter, } else { expression_string = static_cast<MemberExpression const&>(*m_callee).to_string_approximation(); } - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotAEvaluatedFrom, callee_value.to_string_without_side_effects(), call_type, expression_string); + return vm.throw_completion<TypeError>(ErrorType::IsNotAEvaluatedFrom, callee_value.to_string_without_side_effects(), call_type, expression_string); } else { - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, callee_value.to_string_without_side_effects(), call_type); + return vm.throw_completion<TypeError>(ErrorType::IsNotA, callee_value.to_string_without_side_effects(), call_type); } } @@ -494,7 +493,7 @@ Completion SuperCall::execute(Interpreter& interpreter) const // 5. If IsConstructor(func) is false, throw a TypeError exception. if (!func || !Value(func).is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, "Super constructor"); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, "Super constructor"); // 6. Let result be ? Construct(func, argList, newTarget). auto* result = TRY(construct(global_object, static_cast<FunctionObject&>(*func), move(arg_list), &new_target.as_function())); @@ -1201,7 +1200,7 @@ Completion ForAwaitOfStatement::loop_evaluation(Interpreter& interpreter, Vector // c. If Type(nextResult) is not Object, throw a TypeError exception. if (!next_result.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IterableNextBadReturn); + return vm.throw_completion<TypeError>(ErrorType::IterableNextBadReturn); // d. Let done be ? IteratorComplete(nextResult). auto done = TRY(iterator_complete(global_object, next_result.as_object())); @@ -1260,7 +1259,7 @@ Completion BinaryExpression::execute(Interpreter& interpreter) const auto rhs_result = TRY(m_rhs->execute(interpreter)).release_value(); if (!rhs_result.is_object()) - return interpreter.vm().throw_completion<TypeError>(global_object, ErrorType::InOperatorWithObject); + return interpreter.vm().throw_completion<TypeError>(ErrorType::InOperatorWithObject); auto* private_environment = interpreter.vm().running_execution_context().private_environment; VERIFY(private_environment); auto private_name = private_environment->resolve_private_identifier(private_identifier); @@ -1856,11 +1855,11 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::class_definition_e if (super_class.is_null()) { proto_parent = nullptr; } else if (!super_class.is_constructor()) { - return vm.throw_completion<TypeError>(global_object, ErrorType::ClassExtendsValueNotAConstructorOrNull, super_class.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueNotAConstructorOrNull, super_class.to_string_without_side_effects()); } else { auto super_class_prototype = TRY(super_class.get(global_object, vm.names.prototype)); if (!super_class_prototype.is_null() && !super_class_prototype.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ClassExtendsValueInvalidPrototype, super_class_prototype.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ClassExtendsValueInvalidPrototype, super_class_prototype.to_string_without_side_effects()); if (super_class_prototype.is_null()) proto_parent = nullptr; @@ -4555,18 +4554,18 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i TRY(for_each_lexically_declared_name([&](FlyString const& name) -> ThrowCompletionOr<void> { // a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception. if (global_environment.has_var_declaration(name)) - return interpreter.vm().throw_completion<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name); + return interpreter.vm().throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name); // b. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception. if (global_environment.has_lexical_declaration(name)) - return interpreter.vm().throw_completion<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name); + return interpreter.vm().throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name); // c. Let hasRestrictedGlobal be ? env.HasRestrictedGlobalProperty(name). auto has_restricted_global = TRY(global_environment.has_restricted_global_property(name)); // d. If hasRestrictedGlobal is true, throw a SyntaxError exception. if (has_restricted_global) - return interpreter.vm().throw_completion<SyntaxError>(global_object, ErrorType::RestrictedGlobalProperty, name); + return interpreter.vm().throw_completion<SyntaxError>(ErrorType::RestrictedGlobalProperty, name); return {}; })); @@ -4575,7 +4574,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i TRY(for_each_var_declared_name([&](auto const& name) -> ThrowCompletionOr<void> { // a. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception. if (global_environment.has_lexical_declaration(name)) - return interpreter.vm().throw_completion<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name); + return interpreter.vm().throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name); return {}; })); @@ -4607,7 +4606,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i // 2. If fnDefinable is false, throw a TypeError exception. if (!function_definable) - return interpreter.vm().throw_completion<TypeError>(global_object, ErrorType::CannotDeclareGlobalFunction, function.name()); + return interpreter.vm().throw_completion<TypeError>(ErrorType::CannotDeclareGlobalFunction, function.name()); // 3. Append fn to declaredFunctionNames. // Note: Already done in step iv. above. @@ -4636,7 +4635,7 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(Interpreter& i // b. If vnDefinable is false, throw a TypeError exception. if (!var_definable) - return interpreter.vm().throw_completion<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name); + return interpreter.vm().throw_completion<TypeError>(ErrorType::CannotDeclareGlobalVariable, name); // c. If vn is not an element of declaredVarNames, then // i. Append vn to declaredVarNames. diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 705d4e0a57..b2391a9143 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -69,7 +69,7 @@ static ThrowCompletionOr<void> put_by_property_key(Object* object, Value value, case PropertyKind::KeyValue: { bool succeeded = TRY(object->internal_set(name, interpreter.accumulator(), object)); if (!succeeded && interpreter.vm().in_strict_mode()) - return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::ReferenceNullishSetProperty, name, interpreter.accumulator().to_string_without_side_effects()); + return interpreter.vm().throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, name, interpreter.accumulator().to_string_without_side_effects()); break; } case PropertyKind::Spread: @@ -346,7 +346,7 @@ ThrowCompletionOr<void> CreateVariable::execute_impl(Bytecode::Interpreter& inte // Note: This is papering over an issue where "FunctionDeclarationInstantiation" creates these bindings for us. // Instead of crashing in there, we'll just raise an exception here. if (TRY(vm.lexical_environment()->has_binding(name))) - return vm.throw_completion<InternalError>(interpreter.global_object(), String::formatted("Lexical environment already has binding '{}'", name)); + return vm.throw_completion<InternalError>(String::formatted("Lexical environment already has binding '{}'", name)); if (m_is_immutable) vm.lexical_environment()->create_immutable_binding(interpreter.global_object(), name, vm.in_strict_mode()); @@ -481,10 +481,10 @@ ThrowCompletionOr<void> Call::execute_impl(Bytecode::Interpreter& interpreter) c auto callee = interpreter.reg(m_callee); if (m_type == CallType::Call && !callee.is_function()) - return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::IsNotA, callee.to_string_without_side_effects(), "function"sv); + return interpreter.vm().throw_completion<TypeError>(ErrorType::IsNotA, callee.to_string_without_side_effects(), "function"sv); if (m_type == CallType::Construct && !callee.is_constructor()) - return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::IsNotA, callee.to_string_without_side_effects(), "constructor"sv); + return interpreter.vm().throw_completion<TypeError>(ErrorType::IsNotA, callee.to_string_without_side_effects(), "constructor"sv); auto& function = callee.as_function(); @@ -699,7 +699,7 @@ ThrowCompletionOr<void> GetObjectPropertyIterator::execute_impl(Bytecode::Interp auto& realm = *global_object.associated_realm(); auto iterated_object_value = vm.this_value(global_object); if (!iterated_object_value.is_object()) - return vm.throw_completion<InternalError>(global_object, "Invalid state for GetObjectPropertyIterator.next"); + return vm.throw_completion<InternalError>("Invalid state for GetObjectPropertyIterator.next"); auto& iterated_object = iterated_object_value.as_object(); auto* result_object = Object::create(realm, nullptr); diff --git a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp index 6c2701f0fb..c282ccb13f 100644 --- a/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp +++ b/Userland/Libraries/LibJS/Contrib/Test262/$262Object.cpp @@ -71,7 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::detach_array_buffer) { auto array_buffer = vm.argument(0); if (!array_buffer.is_object() || !is<ArrayBuffer>(array_buffer.as_object())) - return vm.throw_completion<TypeError>(global_object); + return vm.throw_completion<TypeError>(); auto& array_buffer_object = static_cast<ArrayBuffer&>(array_buffer.as_object()); TRY(JS::detach_array_buffer(global_object, array_buffer_object, vm.argument(1))); @@ -83,7 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION($262Object::eval_script) auto source = TRY(vm.argument(0).to_string(global_object)); auto script_or_error = Script::parse(source, *vm.current_realm()); if (script_or_error.is_error()) - return vm.throw_completion<SyntaxError>(global_object, script_or_error.error()[0].to_string()); + return vm.throw_completion<SyntaxError>(script_or_error.error()[0].to_string()); TRY(vm.interpreter().run(script_or_error.value())); return js_undefined(); } diff --git a/Userland/Libraries/LibJS/Heap/Heap.cpp b/Userland/Libraries/LibJS/Heap/Heap.cpp index 8c60e20cce..1fef87d439 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.cpp +++ b/Userland/Libraries/LibJS/Heap/Heap.cpp @@ -349,11 +349,4 @@ void Heap::uproot_cell(Cell* cell) m_uprooted_cells.append(cell); } -// Temporary helper function as we can't pass a realm directly until Heap::allocate<T>() and VM::throw_completion<T>() receive one. -// Heap.h and VM.h only have a forward declaration of the GlobalObject, so no inlined member access possible. -Realm& realm_from_global_object(GlobalObject& global_object) -{ - return *global_object.associated_realm(); -} - } diff --git a/Userland/Libraries/LibJS/Heap/Heap.h b/Userland/Libraries/LibJS/Heap/Heap.h index 25e89ebac3..92cbc751ea 100644 --- a/Userland/Libraries/LibJS/Heap/Heap.h +++ b/Userland/Libraries/LibJS/Heap/Heap.h @@ -25,8 +25,6 @@ namespace JS { -Realm& realm_from_global_object(GlobalObject&); - class Heap { AK_MAKE_NONCOPYABLE(Heap); AK_MAKE_NONMOVABLE(Heap); diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp index ef15c210b6..5296df6acf 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp @@ -38,7 +38,7 @@ ThrowCompletionOr<Value> require_object_coercible(GlobalObject& global_object, V { auto& vm = global_object.vm(); if (value.is_nullish()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotObjectCoercible, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotObjectCoercible, value.to_string_without_side_effects()); return value; } @@ -53,7 +53,7 @@ ThrowCompletionOr<Value> call_impl(GlobalObject& global_object, Value function, // 2. If IsCallable(F) is false, throw a TypeError exception. if (!function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function.to_string_without_side_effects()); // 3. Return ? F.[[Call]](V, argumentsList). return function.as_function().internal_call(this_value, move(*arguments_list)); @@ -105,7 +105,7 @@ ThrowCompletionOr<MarkedVector<Value>> create_list_from_array_like(GlobalObject& // 2. If Type(obj) is not Object, throw a TypeError exception. if (!value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, value.to_string_without_side_effects()); auto& array_like = value.as_object(); @@ -151,7 +151,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(GlobalObject& global_obje // 3. If Type(C) is not Object, throw a TypeError exception. if (!constructor.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); // 4. Let S be ? Get(C, @@species). auto species = TRY(constructor.as_object().get(*vm.well_known_symbol_species())); @@ -165,7 +165,7 @@ ThrowCompletionOr<FunctionObject*> species_constructor(GlobalObject& global_obje return &species.as_function(); // 7. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, species.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, species.to_string_without_side_effects()); } // 7.3.25 GetFunctionRealm ( obj ), https://tc39.es/ecma262/#sec-getfunctionrealm @@ -196,7 +196,7 @@ ThrowCompletionOr<Realm*> get_function_realm(GlobalObject& global_object, Functi // a. If obj.[[ProxyHandler]] is null, throw a TypeError exception. if (proxy.is_revoked()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // b. Let proxyTarget be obj.[[ProxyTarget]]. auto& proxy_target = proxy.target(); @@ -595,7 +595,7 @@ ThrowCompletionOr<Value> perform_eval(GlobalObject& global_object, Value x, Call // b. If script is a List of errors, throw a SyntaxError exception. if (parser.has_errors()) { auto& error = parser.errors()[0]; - return vm.throw_completion<SyntaxError>(global_object, error.to_string()); + return vm.throw_completion<SyntaxError>(error.to_string()); } bool strict_eval = false; @@ -697,7 +697,7 @@ ThrowCompletionOr<Value> perform_eval(GlobalObject& global_object, Value x, Call if (auto* bytecode_interpreter = Bytecode::Interpreter::current()) { auto executable_result = Bytecode::Generator::generate(program); if (executable_result.is_error()) - return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string()); + return vm.throw_completion<InternalError>(ErrorType::NotImplemented, executable_result.error().to_string()); auto executable = executable_result.release_value(); executable->name = "eval"sv; @@ -739,7 +739,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo TRY(program.for_each_var_declared_name([&](auto const& name) -> ThrowCompletionOr<void> { // 1. If varEnv.HasLexicalDeclaration(name) is true, throw a SyntaxError exception. if (global_var_environment->has_lexical_declaration(name)) - return vm.throw_completion<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name); + return vm.throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name); // 2. NOTE: eval will not create a global var declaration that would be shadowed by a global lexical declaration. return {}; @@ -760,7 +760,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo // a. If ! thisEnv.HasBinding(name) is true, then if (MUST(this_environment->has_binding(name))) { // i. Throw a SyntaxError exception. - return vm.throw_completion<SyntaxError>(global_object, ErrorType::TopLevelVariableAlreadyDeclared, name); + return vm.throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name); // FIXME: ii. NOTE: Annex B.3.4 defines alternate semantics for the above step. // In particular it only throw the syntax error if it is not an environment from a catchclause. @@ -811,7 +811,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo // b. If fnDefinable is false, throw a TypeError exception. if (!function_definable) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotDeclareGlobalFunction, function.name()); + return vm.throw_completion<TypeError>(ErrorType::CannotDeclareGlobalFunction, function.name()); } // 2. Append fn to declaredFunctionNames. @@ -937,7 +937,7 @@ ThrowCompletionOr<void> eval_declaration_instantiation(VM& vm, GlobalObject& glo // ii. If vnDefinable is false, throw a TypeError exception. if (!variable_definable) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotDeclareGlobalVariable, name); + return vm.throw_completion<TypeError>(ErrorType::CannotDeclareGlobalVariable, name); } // b. If vn is not an element of declaredVarNames, then diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp index 62668cd46b..d968e59307 100644 --- a/Userland/Libraries/LibJS/Runtime/Array.cpp +++ b/Userland/Libraries/LibJS/Runtime/Array.cpp @@ -23,7 +23,7 @@ ThrowCompletionOr<Array*> Array::create(Realm& realm, u64 length, Object* protot // 1. If length > 2^32 - 1, throw a RangeError exception. if (length > NumericLimits<u32>::max()) - return vm.throw_completion<RangeError>(realm.global_object(), ErrorType::InvalidLength, "array"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array"); // 2. If proto is not present, set proto to %Array.prototype%. if (!prototype) @@ -84,7 +84,7 @@ ThrowCompletionOr<bool> Array::set_length(PropertyDescriptor const& property_des auto number_length = TRY(property_descriptor.value->to_number(global_object)); // 5. If newLen is not the same value as numberLen, throw a RangeError exception. if (new_length != number_length.as_double()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "array"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array"); } // 6. Set newLenDesc.[[Value]] to newLen. diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp index c177db0f92..e4806dd6f1 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp @@ -15,7 +15,7 @@ ThrowCompletionOr<ArrayBuffer*> ArrayBuffer::create(Realm& realm, size_t byte_le { auto buffer = ByteBuffer::create_zeroed(byte_length); if (buffer.is_error()) - return realm.vm().throw_completion<RangeError>(realm.global_object(), ErrorType::NotEnoughMemoryToAllocate, byte_length); + return realm.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length); return realm.heap().allocate<ArrayBuffer>(realm, buffer.release_value(), *realm.global_object().array_buffer_prototype()); } @@ -59,7 +59,7 @@ ThrowCompletionOr<ArrayBuffer*> allocate_array_buffer(GlobalObject& global_objec // 2. Let block be ? CreateByteDataBlock(byteLength). auto block = ByteBuffer::create_zeroed(byte_length); if (block.is_error()) - return global_object.vm().throw_completion<RangeError>(global_object, ErrorType::NotEnoughMemoryToAllocate, byte_length); + return global_object.vm().throw_completion<RangeError>(ErrorType::NotEnoughMemoryToAllocate, byte_length); // 3. Set obj.[[ArrayBufferData]] to block. obj->set_buffer(block.release_value()); @@ -84,7 +84,7 @@ ThrowCompletionOr<void> detach_array_buffer(GlobalObject& global_object, ArrayBu // 3. If SameValue(arrayBuffer.[[ArrayBufferDetachKey]], key) is false, throw a TypeError exception. if (!same_value(array_buffer.detach_key(), *key)) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachKeyMismatch, *key, array_buffer.detach_key()); + return vm.throw_completion<TypeError>(ErrorType::DetachKeyMismatch, *key, array_buffer.detach_key()); // 4. Set arrayBuffer.[[ArrayBufferData]] to null. // 5. Set arrayBuffer.[[ArrayBufferByteLength]] to 0. diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp index 1930545e2f..0c936f0e9f 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -39,7 +39,7 @@ void ArrayBufferConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> ArrayBufferConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.ArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ArrayBuffer); } // 25.1.3.1 ArrayBuffer ( length ), https://tc39.es/ecma262/#sec-arraybuffer-length @@ -52,7 +52,7 @@ ThrowCompletionOr<Object*> ArrayBufferConstructor::construct(FunctionObject& new auto error = byte_length_or_error.release_error(); if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { // Re-throw more specific RangeError - return vm.throw_completion<RangeError>(global_object(), ErrorType::InvalidLength, "array buffer"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array buffer"); } return error; } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp index 0b220ad81c..3094f7cd0c 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayBufferPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * Copyright (c) 2021-2022, Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org> * @@ -43,7 +43,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice) // 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. if (array_buffer_object->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 5. Let len be O.[[ArrayBufferByteLength]]. auto length = array_buffer_object->byte_length(); @@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice) // 17. Perform ? RequireInternalSlot(new, [[ArrayBufferData]]). if (!is<ArrayBuffer>(new_array_buffer)) - return vm.throw_completion<TypeError>(global_object, ErrorType::SpeciesConstructorDidNotCreate, "an ArrayBuffer"); + return vm.throw_completion<TypeError>(ErrorType::SpeciesConstructorDidNotCreate, "an ArrayBuffer"); auto* new_array_buffer_object = static_cast<ArrayBuffer*>(new_array_buffer); // 18. If IsSharedArrayBuffer(new) is true, throw a TypeError exception. @@ -95,20 +95,20 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayBufferPrototype::slice) // 19. If IsDetachedBuffer(new) is true, throw a TypeError exception. if (new_array_buffer_object->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::SpeciesConstructorReturned, "a detached ArrayBuffer"); + return vm.throw_completion<TypeError>(ErrorType::SpeciesConstructorReturned, "a detached ArrayBuffer"); // 20. If SameValue(new, O) is true, throw a TypeError exception. if (same_value(new_array_buffer_object, array_buffer_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::SpeciesConstructorReturned, "same ArrayBuffer instance"); + return vm.throw_completion<TypeError>(ErrorType::SpeciesConstructorReturned, "same ArrayBuffer instance"); // 21. If new.[[ArrayBufferByteLength]] < newLen, throw a TypeError exception. if (new_array_buffer_object->byte_length() < new_length) - return vm.throw_completion<TypeError>(global_object, ErrorType::SpeciesConstructorReturned, "an ArrayBuffer smaller than requested"); + return vm.throw_completion<TypeError>(ErrorType::SpeciesConstructorReturned, "an ArrayBuffer smaller than requested"); // 22. NOTE: Side-effects of the above steps may have detached O. // 23. If IsDetachedBuffer(O) is true, throw a TypeError exception. if (array_buffer_object->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 24. Let fromBuf be O.[[ArrayBufferData]]. // 25. Let toBuf be new.[[ArrayBufferData]]. diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index 2fc769b1ee..4f6351b00f 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -68,7 +68,7 @@ ThrowCompletionOr<Object*> ArrayConstructor::construct(FunctionObject& new_targe } else { int_length = MUST(length.to_u32(global_object)); if (int_length != length.as_double()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "array"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "array"); } TRY(array->set(vm.names.length, Value(int_length), Object::ShouldThrowExceptions::Yes)); return array; @@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) if (!vm.argument(1).is_undefined()) { auto callback = vm.argument(1); if (!callback.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_string_without_side_effects()); map_fn = &callback.as_function(); } @@ -112,7 +112,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from) size_t k = 0; while (true) { if (k >= MAX_ARRAY_LIKE_INDEX) { - auto error = vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + auto error = vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); return TRY(iterator_close(global_object, iterator, move(error))); } diff --git a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp index ffaa276bb4..00e126eba6 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayIteratorPrototype.cpp @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayIteratorPrototype::next) auto& typed_array = static_cast<TypedArrayBase&>(array); if (typed_array.viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); length = typed_array.array_length(); } else { diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index a38874d0ad..9e66aa5b81 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -144,7 +144,7 @@ static ThrowCompletionOr<Object*> array_species_create(GlobalObject& global_obje return TRY(Array::create(realm, length)); if (!constructor.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); return TRY(construct(global_object, constructor.as_function(), Value(length))); } @@ -199,7 +199,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat) auto length = TRY(length_of_array_like(global_object, obj)); if (n + length > MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); while (k < length) { auto k_exists = TRY(obj.has_property(k)); if (k_exists) { @@ -211,7 +211,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::concat) } } else { if (n >= MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); TRY(new_array->create_data_property_or_throw(n, arg)); ++n; } @@ -317,7 +317,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::every) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. Let k be 0. // 5. Repeat, while k < len, @@ -403,7 +403,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::filter) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. Let A be ? ArraySpeciesCreate(O, 0). auto* array = TRY(array_species_create(global_object, *object, 0)); @@ -461,7 +461,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find) // 3. If IsCallable(predicate) is false, throw a TypeError exception. if (!predicate.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, predicate.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_string_without_side_effects()); // 4. Let k be 0. // 5. Repeat, while k < len, @@ -500,7 +500,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_index) // 3. If IsCallable(predicate) is false, throw a TypeError exception. if (!predicate.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, predicate.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_string_without_side_effects()); // 4. Let k be 0. // 5. Repeat, while k < len, @@ -539,7 +539,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last) // 3. If IsCallable(predicate) is false, throw a TypeError exception. if (!predicate.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, predicate.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_string_without_side_effects()); // 4. Let k be len - 1. // 5. Repeat, while k โฅ 0, @@ -578,7 +578,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::find_last_index) // 3. If IsCallable(predicate) is false, throw a TypeError exception. if (!predicate.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, predicate.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, predicate.to_string_without_side_effects()); // 4. Let k be len - 1. // 5. Repeat, while k โฅ 0, @@ -621,7 +621,7 @@ static ThrowCompletionOr<size_t> flatten_into_array(GlobalObject& global_object, if (depth > 0 && TRY(value.is_array(global_object))) { if (vm.did_reach_stack_space_limit()) - return vm.throw_completion<InternalError>(global_object, ErrorType::CallStackSizeExceeded); + return vm.throw_completion<InternalError>(ErrorType::CallStackSizeExceeded); auto length = TRY(length_of_array_like(global_object, value.as_object())); target_index = TRY(flatten_into_array(global_object, new_array, value.as_object(), length, target_index, depth - 1)); @@ -629,7 +629,7 @@ static ThrowCompletionOr<size_t> flatten_into_array(GlobalObject& global_object, } if (target_index >= MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::InvalidIndex); + return vm.throw_completion<TypeError>(ErrorType::InvalidIndex); TRY(new_array.create_data_property_or_throw(target_index, value)); @@ -671,7 +671,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::flat_map) // 3. If IsCallable(mapperFunction) is false, throw a TypeError exception. if (!mapper_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, mapper_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, mapper_function.to_string_without_side_effects()); // 4. Let A be ? ArraySpeciesCreate(O, 0). auto* array = TRY(array_species_create(global_object, *object, 0)); @@ -697,7 +697,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::for_each) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. Let k be 0. // 5. Repeat, while k < len, @@ -768,7 +768,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 5. Let groups be a new empty List. OrderedHashMap<PropertyKey, MarkedVector<Value>> groups; @@ -824,7 +824,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::group_to_map) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); struct KeyedGroupTraits : public Traits<Handle<Value>> { static unsigned hash(Handle<Value> const& value_handle) @@ -1109,7 +1109,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::map) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. Let A be ? ArraySpeciesCreate(O, len). auto* array = TRY(array_species_create(global_object, *object, length)); @@ -1166,7 +1166,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::push) auto argument_count = vm.argument_count(); auto new_length = length + argument_count; if (new_length > MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); for (size_t i = 0; i < argument_count; ++i) TRY(this_object->set(length + i, vm.argument(i), Object::ShouldThrowExceptions::Yes)); auto new_length_value = Value(new_length); @@ -1188,11 +1188,11 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. If len = 0 and initialValue is not present, throw a TypeError exception. if (length == 0 && vm.argument_count() <= 1) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); // 5. Let k be 0. size_t k = 0; @@ -1229,7 +1229,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce) // c. If kPresent is false, throw a TypeError exception. if (!k_present) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); } // 9. Repeat, while k < len, @@ -1270,11 +1270,11 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. If len = 0 and initialValue is not present, throw a TypeError exception. if (length == 0 && vm.argument_count() <= 1) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); // 5. Let k be len - 1. ssize_t k = length - 1; @@ -1311,7 +1311,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::reduce_right) // c. If kPresent is false, throw a TypeError exception. if (!k_present) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); } // 9. Repeat, while k โฅ 0, @@ -1470,7 +1470,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::some) // 3. If IsCallable(callbackfn) is false, throw a TypeError exception. if (!callback_function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback_function.to_string_without_side_effects()); // 4. Let k be 0. // 5. Repeat, while k < len, @@ -1566,7 +1566,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort) // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. auto comparefn = vm.argument(0); if (!comparefn.is_undefined() && !comparefn.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, comparefn.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, comparefn.to_string_without_side_effects()); // 2. Let obj be ? ToObject(this value). auto* object = TRY(vm.this_value(global_object).to_object(global_object)); @@ -1642,7 +1642,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice) double new_length = initial_length + insert_count - actual_delete_count; if (new_length > MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); auto* removed_elements = TRY(array_species_create(global_object, *this_object, actual_delete_count)); @@ -1795,7 +1795,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_sorted) // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. if (!comparefn.is_undefined() && !comparefn.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, comparefn); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, comparefn); // 2. Let O be ? ToObject(this value). auto* object = TRY(vm.this_value(global_object).to_object(global_object)); @@ -1892,7 +1892,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_spliced) // 12. If newLen > 2^53 - 1, throw a TypeError exception. if (new_length_double > MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); auto new_length = static_cast<u64>(new_length_double); @@ -1985,7 +1985,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::unshift) size_t new_length = length + arg_count; if (arg_count > 0) { if (new_length > MAX_ARRAY_LIKE_INDEX) - return vm.throw_completion<TypeError>(global_object, ErrorType::ArrayMaxSize); + return vm.throw_completion<TypeError>(ErrorType::ArrayMaxSize); for (size_t k = length; k > 0; --k) { auto from = k - 1; @@ -2046,7 +2046,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::with) // 6. If actualIndex โฅ len or actualIndex < 0, throw a RangeError exception. if (actual_index >= static_cast<double>(length) || actual_index < 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::IndexOutOfRange, actual_index, length); + return vm.throw_completion<RangeError>(ErrorType::IndexOutOfRange, actual_index, length); // 7. Let A be ? ArrayCreate(๐ฝ(len)). auto* array = TRY(Array::create(realm, length)); diff --git a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp index 3b0d17f2d1..8c3e7836b5 100644 --- a/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/AtomicsObject.cpp @@ -33,14 +33,14 @@ static ThrowCompletionOr<ArrayBuffer*> validate_integer_typed_array(GlobalObject if (waitable) { // a. If typedArray.[[TypedArrayName]] is not "Int32Array" or "BigInt64Array", throw a TypeError exception. if ((type_name != vm.names.Int32Array.as_string()) && (type_name != vm.names.BigInt64Array.as_string())) - return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayTypeIsNot, type_name, "Int32 or BigInt64"sv); + return vm.throw_completion<TypeError>(ErrorType::TypedArrayTypeIsNot, type_name, "Int32 or BigInt64"sv); } // 5. Else, else { // a. Let type be TypedArrayElementType(typedArray). // b. If IsUnclampedIntegerElementType(type) is false and IsBigIntElementType(type) is false, throw a TypeError exception. if (!typed_array.is_unclamped_integer_element_type() && !typed_array.is_bigint_element_type()) - return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayTypeIsNot, type_name, "an unclamped integer or BigInt"sv); + return vm.throw_completion<TypeError>(ErrorType::TypedArrayTypeIsNot, type_name, "an unclamped integer or BigInt"sv); } // 6. Return buffer. @@ -62,7 +62,7 @@ static ThrowCompletionOr<size_t> validate_atomic_access(GlobalObject& global_obj // 4. If accessIndex โฅ length, throw a RangeError exception. if (access_index >= length) - return vm.throw_completion<RangeError>(global_object, ErrorType::IndexOutOfRange, access_index, typed_array.array_length()); + return vm.throw_completion<RangeError>(ErrorType::IndexOutOfRange, access_index, typed_array.array_length()); // 5. Let elementSize be TypedArrayElementSize(typedArray). auto element_size = typed_array.element_size(); @@ -96,7 +96,7 @@ static ThrowCompletionOr<Value> atomic_read_modify_write(GlobalObject& global_ob // 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 6. NOTE: The above check is not redundant with the check in ValidateIntegerTypedArray because the call to ToBigInt or ToIntegerOrInfinity on the preceding lines can have arbitrary side effects, which could cause the buffer to become detached. @@ -224,7 +224,7 @@ static ThrowCompletionOr<Value> atomic_compare_exchange_impl(GlobalObject& globa // 6. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (buffer->is_detached()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.template throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 7. NOTE: The above check is not redundant with the check in ValidateIntegerTypedArray because the call to ToBigInt or ToIntegerOrInfinity on the preceding lines can have arbitrary side effects, which could cause the buffer to become detached. @@ -323,7 +323,7 @@ JS_DEFINE_NATIVE_FUNCTION(AtomicsObject::load) // 3. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (typed_array->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 4. NOTE: The above check is not redundant with the check in ValidateIntegerTypedArray because the call to ValidateAtomicAccess on the preceding line can have arbitrary side effects, which could cause the buffer to become detached. @@ -370,7 +370,7 @@ JS_DEFINE_NATIVE_FUNCTION(AtomicsObject::store) // 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (typed_array->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 6. NOTE: The above check is not redundant with the check in ValidateIntegerTypedArray because the call to ToBigInt or ToIntegerOrInfinity on the preceding lines can have arbitrary side effects, which could cause the buffer to become detached. diff --git a/Userland/Libraries/LibJS/Runtime/BigInt.cpp b/Userland/Libraries/LibJS/Runtime/BigInt.cpp index f86b5f5bc3..fdb830de96 100644 --- a/Userland/Libraries/LibJS/Runtime/BigInt.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigInt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -35,7 +35,7 @@ ThrowCompletionOr<BigInt*> number_to_bigint(GlobalObject& global_object, Value n // 1. If IsIntegralNumber(number) is false, throw a RangeError exception. if (!number.is_integral_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::BigIntFromNonIntegral); + return vm.throw_completion<RangeError>(ErrorType::BigIntFromNonIntegral); // 2. Return the BigInt value that represents โ(number). return js_bigint(vm, Crypto::SignedBigInteger::create_from((i64)number.as_double())); diff --git a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp index 815a07e77c..e4747fed36 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -59,7 +59,7 @@ ThrowCompletionOr<Value> BigIntConstructor::call() // 21.2.1.1 BigInt ( value ), https://tc39.es/ecma262/#sec-bigint-constructor-number-value ThrowCompletionOr<Object*> BigIntConstructor::construct(FunctionObject&) { - return vm().throw_completion<TypeError>(global_object(), ErrorType::NotAConstructor, "BigInt"); + return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "BigInt"); } // 21.2.2.1 BigInt.asIntN ( bits, bigint ), https://tc39.es/ecma262/#sec-bigint.asintn diff --git a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp index 8e3b97ea12..9de1d8ff43 100644 --- a/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -43,7 +43,7 @@ static ThrowCompletionOr<BigInt*> this_bigint_value(GlobalObject& global_object, if (value.is_object() && is<BigIntObject>(value.as_object())) return &static_cast<BigIntObject&>(value.as_object()).bigint(); auto& vm = global_object.vm(); - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "BigInt"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "BigInt"); } // 21.2.3.3 BigInt.prototype.toString ( [ radix ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tostring @@ -54,7 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string) if (!vm.argument(0).is_undefined()) { radix = TRY(vm.argument(0).to_integer_or_infinity(global_object)); if (radix < 2 || radix > 36) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidRadix); + return vm.throw_completion<RangeError>(ErrorType::InvalidRadix); } return js_string(vm, bigint->big_integer().to_base(radix)); } diff --git a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp index 67e0e9fbd7..2bf9922cc8 100644 --- a/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/BooleanPrototype.cpp @@ -33,7 +33,7 @@ JS_DEFINE_NATIVE_FUNCTION(BooleanPrototype::to_string) if (this_value.is_boolean()) return js_string(vm, this_value.as_bool() ? "true" : "false"); if (!this_value.is_object() || !is<BooleanObject>(this_value.as_object())) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Boolean"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Boolean"); bool bool_value = static_cast<BooleanObject const&>(this_value.as_object()).boolean(); return js_string(vm, bool_value ? "true" : "false"); @@ -46,7 +46,7 @@ JS_DEFINE_NATIVE_FUNCTION(BooleanPrototype::value_of) if (this_value.is_boolean()) return this_value; if (!this_value.is_object() || !is<BooleanObject>(this_value.as_object())) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Boolean"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Boolean"); return Value(static_cast<BooleanObject const&>(this_value.as_object()).boolean()); } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp index 10e054e80e..e62c1eb28d 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewConstructor.cpp @@ -33,7 +33,7 @@ void DataViewConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> DataViewConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.DataView); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.DataView); } // 25.3.2.1 DataView ( buffer [ , byteOffset [ , byteLength ] ] ), https://tc39.es/ecma262/#sec-dataview-buffer-byteoffset-bytelength @@ -44,18 +44,18 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta auto buffer = vm.argument(0); if (!buffer.is_object() || !is<ArrayBuffer>(buffer.as_object())) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotAn, buffer.to_string_without_side_effects(), vm.names.ArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::IsNotAn, buffer.to_string_without_side_effects(), vm.names.ArrayBuffer); auto& array_buffer = static_cast<ArrayBuffer&>(buffer.as_object()); auto offset = TRY(vm.argument(1).to_index(global_object)); if (array_buffer.is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); auto buffer_byte_length = array_buffer.byte_length(); if (offset > buffer_byte_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::DataViewOutOfRangeByteOffset, offset, buffer_byte_length); + return vm.throw_completion<RangeError>(ErrorType::DataViewOutOfRangeByteOffset, offset, buffer_byte_length); size_t view_byte_length; if (vm.argument(2).is_undefined()) { @@ -64,13 +64,13 @@ ThrowCompletionOr<Object*> DataViewConstructor::construct(FunctionObject& new_ta view_byte_length = TRY(vm.argument(2).to_index(global_object)); auto const checked_add = AK::make_checked(view_byte_length) + AK::make_checked(offset); if (checked_add.has_overflow() || checked_add.value() > buffer_byte_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, vm.names.DataView); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, vm.names.DataView); } auto* data_view = TRY(ordinary_create_from_constructor<DataView>(global_object, new_target, &GlobalObject::data_view_prototype, &array_buffer, view_byte_length, offset)); if (array_buffer.is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); return data_view; } diff --git a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp index 2c2b050b77..44c32f9594 100644 --- a/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DataViewPrototype.cpp @@ -61,7 +61,7 @@ static ThrowCompletionOr<Value> get_view_value(GlobalObject& global_object, Valu auto buffer = view->viewed_array_buffer(); if (buffer->is_detached()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.template throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); auto view_offset = view->byte_offset(); auto view_size = view->byte_length(); @@ -75,7 +75,7 @@ static ThrowCompletionOr<Value> get_view_value(GlobalObject& global_object, Valu end_index += element_size; if (buffer_index.has_overflow() || end_index.has_overflow() || end_index.value() > view_size) - return vm.throw_completion<RangeError>(global_object, ErrorType::DataViewOutOfRangeByteOffset, get_index, view_size); + return vm.throw_completion<RangeError>(ErrorType::DataViewOutOfRangeByteOffset, get_index, view_size); return buffer->get_value<T>(buffer_index.value(), false, ArrayBuffer::Order::Unordered, little_endian); } @@ -98,7 +98,7 @@ static ThrowCompletionOr<Value> set_view_value(GlobalObject& global_object, Valu auto buffer = view->viewed_array_buffer(); if (buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); auto view_offset = view->byte_offset(); auto view_size = view->byte_length(); @@ -112,7 +112,7 @@ static ThrowCompletionOr<Value> set_view_value(GlobalObject& global_object, Valu end_index += element_size; if (buffer_index.has_overflow() || end_index.has_overflow() || end_index.value() > view_size) - return vm.throw_completion<RangeError>(global_object, ErrorType::DataViewOutOfRangeByteOffset, get_index, view_size); + return vm.throw_completion<RangeError>(ErrorType::DataViewOutOfRangeByteOffset, get_index, view_size); buffer->set_value<T>(buffer_index.value(), number_value, false, ArrayBuffer::Order::Unordered, little_endian); @@ -242,7 +242,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::byte_length_getter) { auto* data_view = TRY(typed_this_value(global_object)); if (data_view->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); return Value(data_view->byte_length()); } @@ -251,7 +251,7 @@ JS_DEFINE_NATIVE_FUNCTION(DataViewPrototype::byte_offset_getter) { auto* data_view = TRY(typed_this_value(global_object)); if (data_view->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); return Value(data_view->byte_offset()); } diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 61a9feae2c..371b959160 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -109,7 +109,7 @@ ThrowCompletionOr<double> this_time_value(GlobalObject& global_object, Value val // 2. Throw a TypeError exception. auto& vm = global_object.vm(); - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Date"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Date"); } // 21.4.4.2 Date.prototype.getDate ( ), https://tc39.es/ecma262/#sec-date.prototype.getdate @@ -969,7 +969,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string) auto* this_object = TRY(typed_this_object(global_object)); if (!Value(this_object->date_value()).is_finite_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidTimeValue); + return vm.throw_completion<RangeError>(ErrorType::InvalidTimeValue); auto string = this_object->iso_date_string(); return js_string(vm, move(string)); @@ -1241,10 +1241,10 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive) { auto this_value = vm.this_value(global_object); if (!this_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, this_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, this_value.to_string_without_side_effects()); auto hint_value = vm.argument(0); if (!hint_value.is_string()) - return vm.throw_completion<TypeError>(global_object, ErrorType::InvalidHint, hint_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::InvalidHint, hint_value.to_string_without_side_effects()); auto& hint = hint_value.as_string().string(); Value::PreferredType try_first; if (hint == "string" || hint == "default") @@ -1252,7 +1252,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive) else if (hint == "number") try_first = Value::PreferredType::Number; else - return vm.throw_completion<TypeError>(global_object, ErrorType::InvalidHint, hint); + return vm.throw_completion<TypeError>(ErrorType::InvalidHint, hint); return TRY(this_value.as_object().ordinary_to_primitive(try_first)); } diff --git a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp index 4e30e50335..c16e16a329 100644 --- a/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/DeclarativeEnvironment.cpp @@ -129,7 +129,7 @@ ThrowCompletionOr<void> DeclarativeEnvironment::set_mutable_binding(GlobalObject if (!index.has_value()) { // a. If S is true, throw a ReferenceError exception. if (strict) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::UnknownIdentifier, name); + return vm().throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, name); // b. Perform ! envRec.CreateMutableBinding(N, true). MUST(create_mutable_binding(global_object, name, true)); @@ -148,20 +148,20 @@ ThrowCompletionOr<void> DeclarativeEnvironment::set_mutable_binding(GlobalObject return {}; } -ThrowCompletionOr<void> DeclarativeEnvironment::set_mutable_binding_direct(GlobalObject& global_object, size_t index, Value value, bool strict) +ThrowCompletionOr<void> DeclarativeEnvironment::set_mutable_binding_direct(GlobalObject&, size_t index, Value value, bool strict) { auto& binding = m_bindings[index]; if (binding.strict) strict = true; if (!binding.initialized) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::BindingNotInitialized, binding.name); + return vm().throw_completion<ReferenceError>(ErrorType::BindingNotInitialized, binding.name); if (binding.mutable_) { binding.value = value; } else { if (strict) - return vm().throw_completion<TypeError>(global_object, ErrorType::InvalidAssignToConst); + return vm().throw_completion<TypeError>(ErrorType::InvalidAssignToConst); } return {}; @@ -178,13 +178,13 @@ ThrowCompletionOr<Value> DeclarativeEnvironment::get_binding_value(GlobalObject& return get_binding_value_direct(global_object, *index, strict); } -ThrowCompletionOr<Value> DeclarativeEnvironment::get_binding_value_direct(GlobalObject& global_object, size_t index, bool) +ThrowCompletionOr<Value> DeclarativeEnvironment::get_binding_value_direct(GlobalObject&, size_t index, bool) { auto& binding = m_bindings[index]; // 2. If the binding for N in envRec is an uninitialized binding, throw a ReferenceError exception. if (!binding.initialized) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::BindingNotInitialized, binding.name); + return vm().throw_completion<ReferenceError>(ErrorType::BindingNotInitialized, binding.name); // 3. Return the value currently bound to N in envRec. return binding.value; diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index 68eec33529..6fc2397b38 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -160,7 +160,7 @@ ThrowCompletionOr<Value> ECMAScriptFunctionObject::internal_call(Value this_argu if (m_is_class_constructor) { // a. Let error be a newly created TypeError object. // b. NOTE: error is created in calleeContext with F's associated Realm Record. - auto throw_completion = vm.throw_completion<TypeError>(global_object(), ErrorType::ClassConstructorWithoutNew, m_name); + auto throw_completion = vm.throw_completion<TypeError>(ErrorType::ClassConstructorWithoutNew, m_name); // c. Remove calleeContext from the execution context stack and restore callerContext as the running execution context. vm.pop_execution_context(); @@ -274,7 +274,7 @@ ThrowCompletionOr<Object*> ECMAScriptFunctionObject::internal_construct(MarkedVe // c. If result.[[Value]] is not undefined, throw a TypeError exception. if (!result.value()->is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DerivedConstructorReturningInvalidValue); + return vm.throw_completion<TypeError>(ErrorType::DerivedConstructorReturningInvalidValue); } // 11. Else, ReturnIfAbrupt(result). else if (result.is_abrupt()) { @@ -787,14 +787,14 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() auto* bytecode_interpreter = Bytecode::Interpreter::current(); if (m_kind == FunctionKind::AsyncGenerator) - return vm.throw_completion<InternalError>(global_object, ErrorType::NotImplemented, "Async Generator function execution"); + return vm.throw_completion<InternalError>(ErrorType::NotImplemented, "Async Generator function execution"); if (bytecode_interpreter) { if (!m_bytecode_executable) { auto compile = [&](auto& node, auto kind, auto name) -> ThrowCompletionOr<NonnullOwnPtr<Bytecode::Executable>> { auto executable_result = Bytecode::Generator::generate(node, kind); if (executable_result.is_error()) - return vm.throw_completion<InternalError>(bytecode_interpreter->global_object(), ErrorType::NotImplemented, executable_result.error().to_string()); + return vm.throw_completion<InternalError>(ErrorType::NotImplemented, executable_result.error().to_string()); auto bytecode_executable = executable_result.release_value(); bytecode_executable->name = name; @@ -845,7 +845,7 @@ Completion ECMAScriptFunctionObject::ordinary_call_evaluate_body() return { Completion::Type::Return, generator_object, {} }; } else { if (m_kind == FunctionKind::Generator) - return vm.throw_completion<InternalError>(global_object, ErrorType::NotImplemented, "Generator function execution in AST interpreter"); + return vm.throw_completion<InternalError>(ErrorType::NotImplemented, "Generator function execution in AST interpreter"); OwnPtr<Interpreter> local_interpreter; Interpreter* ast_interpreter = vm.interpreter_if_exists(); diff --git a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp index 1aae7414b3..f5ea250684 100644 --- a/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ErrorPrototype.cpp @@ -110,14 +110,14 @@ JS_DEFINE_NATIVE_FUNCTION(ErrorPrototype::stack_setter) // 2. If ! Type(E) is not Object, throw a TypeError exception. if (!this_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, this_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, this_value.to_string_without_side_effects()); auto& this_object = this_value.as_object(); // 3. Let numberOfArgs be the number of arguments passed to this function call. // 4. If numberOfArgs is 0, throw a TypeError exception. if (vm.argument_count() == 0) - return vm.throw_completion<TypeError>(global_object, ErrorType::BadArgCountOne, "set stack"); + return vm.throw_completion<TypeError>(ErrorType::BadArgCountOne, "set stack"); // 5. Return ? CreateDataPropertyOrThrow(E, "stack", value); return TRY(this_object.create_data_property_or_throw(vm.names.stack, vm.argument(0))); diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp index d693e4a6aa..3796b3ff51 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryConstructor.cpp @@ -33,7 +33,7 @@ void FinalizationRegistryConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> FinalizationRegistryConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.FinalizationRegistry); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.FinalizationRegistry); } // 26.2.1.1 FinalizationRegistry ( cleanupCallback ), https://tc39.es/ecma262/#sec-finalization-registry-cleanup-callback @@ -47,7 +47,7 @@ ThrowCompletionOr<Object*> FinalizationRegistryConstructor::construct(FunctionOb // 2. If IsCallable(cleanupCallback) is false, throw a TypeError exception. auto cleanup_callback = vm.argument(0); if (!cleanup_callback.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, cleanup_callback.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, cleanup_callback.to_string_without_side_effects()); // 3. Let finalizationRegistry be ? OrdinaryCreateFromConstructor(NewTarget, "%FinalizationRegistry.prototype%", ยซ [[Realm]], [[CleanupCallback]], [[Cells]] ยป). // 4. Let fn be the active function object. diff --git a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp index f19b5726bc..9a1f070edb 100644 --- a/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FinalizationRegistryPrototype.cpp @@ -35,7 +35,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some) auto callback = vm.argument(0); if (vm.argument_count() > 0 && !callback.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_string_without_side_effects()); // IMPLEMENTATION DEFINED: The specification for this function hasn't been updated to accommodate for JobCallback records. // This just follows how the constructor immediately converts the callback to a JobCallback using HostMakeJobCallback. @@ -51,15 +51,15 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_) auto target = vm.argument(0); if (!can_be_held_weakly(target)) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects()); auto held_value = vm.argument(1); if (same_value(target, held_value)) - return vm.throw_completion<TypeError>(global_object, ErrorType::FinalizationRegistrySameTargetAndValue); + return vm.throw_completion<TypeError>(ErrorType::FinalizationRegistrySameTargetAndValue); auto unregister_token = vm.argument(2); if (!can_be_held_weakly(unregister_token) && !unregister_token.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, unregister_token.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, unregister_token.to_string_without_side_effects()); finalization_registry->add_finalization_record(target.as_cell(), held_value, unregister_token.is_undefined() ? nullptr : &unregister_token.as_cell()); @@ -73,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::unregister) auto unregister_token = vm.argument(0); if (!can_be_held_weakly(unregister_token)) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, unregister_token.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, unregister_token.to_string_without_side_effects()); return Value(finalization_registry->remove_by_token(unregister_token.as_cell())); } diff --git a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp index 6332d9c180..2895fbc38d 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionConstructor.cpp @@ -179,7 +179,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic // 17. If parameters is a List of errors, throw a SyntaxError exception. if (parameters_parser.has_errors()) { auto error = parameters_parser.errors()[0]; - return vm.throw_completion<SyntaxError>(global_object, error.to_string()); + return vm.throw_completion<SyntaxError>(error.to_string()); } // 18. Let body be ParseText(StringToCodePoints(bodyString), bodySym). @@ -196,7 +196,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic // 19. If body is a List of errors, throw a SyntaxError exception. if (body_parser.has_errors()) { auto error = body_parser.errors()[0]; - return vm.throw_completion<SyntaxError>(global_object, error.to_string()); + return vm.throw_completion<SyntaxError>(error.to_string()); } // 20. NOTE: The parameters and body are parsed separately to ensure that each is valid alone. For example, new Function("/*", "*/ ) {") is not legal. @@ -210,7 +210,7 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic // 23. If expr is a List of errors, throw a SyntaxError exception. if (source_parser.has_errors()) { auto error = source_parser.errors()[0]; - return vm.throw_completion<SyntaxError>(global_object, error.to_string()); + return vm.throw_completion<SyntaxError>(error.to_string()); } // 24. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto). diff --git a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp index 0f371f54d9..e212a2aa58 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp @@ -61,21 +61,21 @@ bool FunctionEnvironment::has_super_binding() const } // 9.1.1.3.4 GetThisBinding ( ), https://tc39.es/ecma262/#sec-function-environment-records-getthisbinding -ThrowCompletionOr<Value> FunctionEnvironment::get_this_binding(GlobalObject& global_object) const +ThrowCompletionOr<Value> FunctionEnvironment::get_this_binding(GlobalObject&) const { // 1. Assert: envRec.[[ThisBindingStatus]] is not lexical. VERIFY(m_this_binding_status != ThisBindingStatus::Lexical); // 2. If envRec.[[ThisBindingStatus]] is uninitialized, throw a ReferenceError exception. if (m_this_binding_status == ThisBindingStatus::Uninitialized) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::ThisHasNotBeenInitialized); + return vm().throw_completion<ReferenceError>(ErrorType::ThisHasNotBeenInitialized); // 3. Return envRec.[[ThisValue]]. return m_this_value; } // 9.1.1.3.1 BindThisValue ( V ), https://tc39.es/ecma262/#sec-bindthisvalue -ThrowCompletionOr<Value> FunctionEnvironment::bind_this_value(GlobalObject& global_object, Value this_value) +ThrowCompletionOr<Value> FunctionEnvironment::bind_this_value(GlobalObject&, Value this_value) { VERIFY(!this_value.is_empty()); @@ -84,7 +84,7 @@ ThrowCompletionOr<Value> FunctionEnvironment::bind_this_value(GlobalObject& glob // 2. If envRec.[[ThisBindingStatus]] is initialized, throw a ReferenceError exception. if (m_this_binding_status == ThisBindingStatus::Initialized) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::ThisIsAlreadyInitialized); + return vm().throw_completion<ReferenceError>(ErrorType::ThisIsAlreadyInitialized); // 3. Set envRec.[[ThisValue]] to V. m_this_value = this_value; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index d401128c41..248d135938 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -54,7 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::apply) // 2. If IsCallable(func) is false, throw a TypeError exception. if (!function_value.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, function_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function_value.to_string_without_side_effects()); auto& function = static_cast<FunctionObject&>(function_value.as_object()); @@ -91,7 +91,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind) // 2. If IsCallable(Target) is false, throw a TypeError exception. if (!target_value.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, target_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target_value.to_string_without_side_effects()); auto& target = static_cast<FunctionObject&>(target_value.as_object()); @@ -122,7 +122,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::call) // 2. If IsCallable(func) is false, throw a TypeError exception. if (!function_value.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, function_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function_value.to_string_without_side_effects()); auto& function = static_cast<FunctionObject&>(function_value.as_object()); @@ -148,7 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // If func is not a function, let's bail out early. The order of this step is not observable. if (!function_value.is_function()) { // 5. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Function"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Function"); } auto& function = function_value.as_function(); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp index 0868fac551..7fbb21e3ff 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalEnvironment.cpp @@ -57,7 +57,7 @@ ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject& // 1. Let DclRec be envRec.[[DeclarativeRecord]]. // 2. If ! DclRec.HasBinding(N) is true, throw a TypeError exception. if (MUST(m_declarative_record->has_binding(name))) - return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name); + return vm().throw_completion<TypeError>(ErrorType::GlobalEnvironmentAlreadyHasBinding, name); // 3. Return ! DclRec.CreateMutableBinding(N, D). return MUST(m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted)); @@ -69,7 +69,7 @@ ThrowCompletionOr<void> GlobalEnvironment::create_immutable_binding(GlobalObject // 1. Let DclRec be envRec.[[DeclarativeRecord]]. // 2. If ! DclRec.HasBinding(N) is true, throw a TypeError exception. if (MUST(m_declarative_record->has_binding(name))) - return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name); + return vm().throw_completion<TypeError>(ErrorType::GlobalEnvironmentAlreadyHasBinding, name); // 3. Return ! DclRec.CreateImmutableBinding(N, S). return MUST(m_declarative_record->create_immutable_binding(global_object, name, strict)); diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp index 0d84028f45..69ff77428f 100644 --- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp @@ -226,8 +226,8 @@ void GlobalObject::initialize_global_object() // 10.2.4.1 %ThrowTypeError% ( ), https://tc39.es/ecma262/#sec-%throwtypeerror% m_throw_type_error_function = NativeFunction::create( - realm, [](VM& vm, GlobalObject& global_object) { - return vm.throw_completion<TypeError>(global_object, ErrorType::RestrictedFunctionPropertiesAccess); + realm, [](VM& vm, GlobalObject&) { + return vm.throw_completion<TypeError>(ErrorType::RestrictedFunctionPropertiesAccess); }, 0, "", &realm); m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0); @@ -533,7 +533,7 @@ static ThrowCompletionOr<String> encode(GlobalObject& global_object, String cons auto code_point = code_point_at(utf16_string.view(), k); // ii. If cp.[[IsUnpairedSurrogate]] is true, throw a URIError exception. if (code_point.is_unpaired_surrogate) - return vm.throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return vm.throw_completion<URIError>(ErrorType::URIMalformed); // iii. Set k to k + cp.[[CodeUnitCount]]. k += code_point.code_unit_count; @@ -563,22 +563,22 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons auto code_unit = string[k]; if (code_unit != '%') { if (expected_continuation_bytes > 0) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); decoded_builder.append(code_unit); continue; } if (k + 2 >= string.length()) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); auto first_digit = decode_hex_digit(string[k + 1]); if (first_digit >= 16) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); auto second_digit = decode_hex_digit(string[k + 2]); if (second_digit >= 16) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); u8 decoded_code_unit = (first_digit << 4) | second_digit; k += 2; @@ -586,7 +586,7 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons decoded_builder.append(decoded_code_unit); expected_continuation_bytes--; if (expected_continuation_bytes == 0 && !Utf8View(decoded_builder.string_view().substring_view(code_point_start_offset)).validate()) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); continue; } @@ -600,14 +600,14 @@ static ThrowCompletionOr<String> decode(GlobalObject& global_object, String cons auto leading_ones = count_leading_zeroes_safe(static_cast<u8>(~decoded_code_unit)); if (leading_ones == 1 || leading_ones > 4) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); code_point_start_offset = decoded_builder.length(); decoded_builder.append(decoded_code_unit); expected_continuation_bytes = leading_ones - 1; } if (expected_continuation_bytes > 0) - return global_object.vm().throw_completion<URIError>(global_object, ErrorType::URIMalformed); + return global_object.vm().throw_completion<URIError>(ErrorType::URIMalformed); return decoded_builder.build(); } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 595c8686f9..78b00cc4e5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -229,7 +229,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(GlobalObject& global_ // ii. If Type(kValue) is not String or Object, throw a TypeError exception. if (!key_value.is_string() && !key_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOrString, key_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrString, key_value.to_string_without_side_effects()); String tag; @@ -247,7 +247,7 @@ ThrowCompletionOr<Vector<String>> canonicalize_locale_list(GlobalObject& global_ // v. If ! IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. auto locale_id = is_structurally_valid_language_tag(tag); if (!locale_id.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidLanguageTag, tag); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, tag); // vi. Let canonicalizedTag be ! CanonicalizeUnicodeLocaleId(tag). auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id); @@ -658,7 +658,7 @@ ThrowCompletionOr<Optional<int>> default_number_option(GlobalObject& global_obje // 3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception. if (value.is_nan() || (value.as_double() < minimum) || (value.as_double() > maximum)) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaNOrOutOfRange, value, minimum, maximum); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaNOrOutOfRange, value, minimum, maximum); // 4. Return floor(value). return floor(value.as_double()); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp index 607a0f2677..0b11a478f5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/CollatorConstructor.cpp @@ -52,7 +52,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(GlobalObject& global_obj if (!collation.is_undefined()) { // a. If collation does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(collation.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, collation, "collation"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, collation, "collation"sv); // 12. Set opt.[[co]] to collation. opt.co = collation.as_string().string(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp index 0d4b0cd844..8fe0713df6 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormat.cpp @@ -119,13 +119,13 @@ ThrowCompletionOr<Object*> to_date_time_options(GlobalObject& global_object, Val // 9. If required is "date" and timeStyle is not undefined, then if ((required == OptionRequired::Date) && !time_style.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlInvalidDateTimeFormatOption, "timeStyle"sv, "date"sv); + return vm.throw_completion<TypeError>(ErrorType::IntlInvalidDateTimeFormatOption, "timeStyle"sv, "date"sv); } // 10. If required is "time" and dateStyle is not undefined, then if ((required == OptionRequired::Time) && !date_style.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlInvalidDateTimeFormatOption, "dateStyle"sv, "time"sv); + return vm.throw_completion<TypeError>(ErrorType::IntlInvalidDateTimeFormatOption, "dateStyle"sv, "time"sv); } // 11. If needDefaults is true and defaults is either "date" or "all", then @@ -540,7 +540,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(GlobalObjec // 2. If x is NaN, throw a RangeError exception. if (isnan(time)) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidTime); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidTime); // 3. Let locale be dateTimeFormat.[[Locale]]. auto const& locale = date_time_format.locale(); @@ -928,14 +928,14 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_date_time_range_ // 2. If x is NaN, throw a RangeError exception. if (isnan(start)) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidTime); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidTime); // 3. Let y be TimeClip(y). end = time_clip(end); // 4. If y is NaN, throw a RangeError exception. if (isnan(end)) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidTime); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidTime); // 5. Let tm1 be ToLocalTime(x, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]). auto start_local_time = TRY(to_local_time(global_object, start, date_time_format.calendar(), date_time_format.time_zone())); @@ -1248,7 +1248,7 @@ ThrowCompletionOr<LocalTime> to_local_time(GlobalObject& global_object, double t // 3. Else, // a. Return a record with the fields of Column 1 of Table 7 calculated from t for the given calendar and timeZone. The calculations should use best available information about the specified calendar and timeZone, including current and historical information about time zone offsets from UTC and daylight saving time rules. // FIXME: Implement this when non-Gregorian calendars are supported by LibUnicode. - return global_object.vm().throw_completion<InternalError>(global_object, ErrorType::NotImplemented, "Non-Gregorian calendars"sv); + return global_object.vm().throw_completion<InternalError>(ErrorType::NotImplemented, "Non-Gregorian calendars"sv); } } diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp index f04ea4f189..3942a506d5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatConstructor.cpp @@ -109,7 +109,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo if (!calendar.is_undefined()) { // a. If calendar does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(calendar.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, calendar, "calendar"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, calendar, "calendar"sv); // 8. Set opt.[[ca]] to calendar. opt.ca = calendar.as_string().string(); @@ -122,7 +122,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo if (!numbering_system.is_undefined()) { // a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(numbering_system.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); // 11. Set opt.[[nu]] to numberingSystem. opt.nu = numbering_system.as_string().string(); @@ -229,7 +229,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo // b. If the result of IsValidTimeZoneName(timeZone) is false, then if (!Temporal::is_valid_time_zone_name(time_zone)) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, time_zone, vm.names.timeZone); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, time_zone, vm.names.timeZone); } // c. Set timeZone to ! CanonicalizeTimeZoneName(timeZone). @@ -312,7 +312,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(GlobalObject& glo // a. If hasExplicitFormatComponents is true, then if (explicit_format_component != nullptr) { // i. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlInvalidDateTimeFormatOption, *explicit_format_component, "dateStyle or timeStyle"sv); + return vm.throw_completion<TypeError>(ErrorType::IntlInvalidDateTimeFormatOption, *explicit_format_component, "dateStyle or timeStyle"sv); } // b. Let styles be dataLocaleData.[[styles]].[[<resolvedCalendar>]]. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp index afd5ab026f..ac6a362213 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DateTimeFormatPrototype.cpp @@ -100,9 +100,9 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range) // 3. If startDate is undefined or endDate is undefined, throw a TypeError exception. if (start_date.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "startDate"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "startDate"sv); if (end_date.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "endDate"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "endDate"sv); // 4. Let x be ? ToNumber(startDate). auto start_date_number = TRY(start_date.to_number(global_object)).as_double(); @@ -127,9 +127,9 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range_to_parts) // 3. If startDate is undefined or endDate is undefined, throw a TypeError exception. if (start_date.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "startDate"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "startDate"sv); if (end_date.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "endDate"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "endDate"sv); // 4. Let x be ? ToNumber(startDate). auto start_date_number = TRY(start_date.to_number(global_object)).as_double(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp index ebbea247d4..d25b2f9d02 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp @@ -109,12 +109,12 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o if (type == DisplayNames::Type::Language) { // a. If code does not match the unicode_language_id production, throw a RangeError exception. if (!Unicode::parse_unicode_language_id(code).has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "language"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "language"sv); // b. If IsStructurallyValidLanguageTag(code) is false, throw a RangeError exception. auto locale_id = is_structurally_valid_language_tag(code); if (!locale_id.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidLanguageTag, code); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, code); // c. Return ! CanonicalizeUnicodeLocaleId(code). auto canonicalized_tag = Intl::canonicalize_unicode_locale_id(*locale_id); @@ -125,7 +125,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o if (type == DisplayNames::Type::Region) { // a. If code does not match the unicode_region_subtag production, throw a RangeError exception. if (!Unicode::is_unicode_region_subtag(code)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "region"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "region"sv); // b. Return the ASCII-uppercase of code. return js_string(vm, code.to_uppercase_string()); @@ -135,7 +135,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o if (type == DisplayNames::Type::Script) { // a. If code does not match the unicode_script_subtag production, throw a RangeError exception. if (!Unicode::is_unicode_script_subtag(code)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "script"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "script"sv); // Assert: The length of code is 4, and every code unit of code represents an ASCII letter (0x0041 through 0x005A and 0x0061 through 0x007A, both inclusive). VERIFY(code.length() == 4); @@ -151,11 +151,11 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o if (type == DisplayNames::Type::Calendar) { // a. If code does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(code)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "calendar"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "calendar"sv); // b. If code uses any of the backwards compatibility syntax described in Unicode Technical Standard #35 LDML ยง 3.3 BCP 47 Conformance, throw a RangeError exception. if (code.contains('_')) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "calendar"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "calendar"sv); // c. Return the ASCII-lowercase of code. return js_string(vm, code.to_lowercase_string()); @@ -165,7 +165,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o if (type == DisplayNames::Type::DateTimeField) { // a. If the result of IsValidDateTimeFieldCode(code) is false, throw a RangeError exception. if (!is_valid_date_time_field_code(code)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "dateTimeField"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "dateTimeField"sv); // b. Return code. return js_string(vm, code); @@ -176,7 +176,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(GlobalObject& global_o // 7. If ! IsWellFormedCurrencyCode(code) is false, throw a RangeError exception. if (!is_well_formed_currency_code(code)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, code, "currency"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "currency"sv); // 8. Return the ASCII-uppercase of code. return js_string(vm, code.to_uppercase_string()); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp index 986e9f9247..a951df5827 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DisplayNamesConstructor.cpp @@ -40,7 +40,7 @@ void DisplayNamesConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> DisplayNamesConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.DisplayNames"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.DisplayNames"); } // 12.1.1 Intl.DisplayNames ( locales, options ), https://tc39.es/ecma402/#sec-Intl.DisplayNames @@ -60,7 +60,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne // 4. If options is undefined, throw a TypeError exception. if (options_value.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "options"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "options"sv); // 5. Set options to ? GetOptionsObject(options). auto* options = TRY(Temporal::get_options_object(global_object, options_value)); @@ -90,7 +90,7 @@ ThrowCompletionOr<Object*> DisplayNamesConstructor::construct(FunctionObject& ne // 14. If type is undefined, throw a TypeError exception. if (type.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "options.type"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "options.type"sv); // 15. Set displayNames.[[Type]] to type. display_names->set_type(type.as_string().string()); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index d552a28b39..6d8e37827d 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -137,7 +137,7 @@ ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(GlobalObject& glo // 1. If Type(input) is not Object, throw a TypeError exception. if (!input.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, input); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, input); auto& input_object = input.as_object(); // 2. Let result be a new Record. @@ -177,7 +177,7 @@ ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(GlobalObject& glo // 5. If any is false, throw a TypeError exception. if (!any) - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalInvalidDurationLikeObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalInvalidDurationLikeObject); // 6. Return result. return result; @@ -281,7 +281,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(GlobalObject& g // a. If style is not "numeric" or "2-digit", then if (style != "numeric"sv && style != "2-digit"sv) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNonNumericOr2DigitAfterNumericOr2Digit); + return vm.throw_completion<RangeError>(ErrorType::IntlNonNumericOr2DigitAfterNumericOr2Digit); } // b. Else if unit is "minutes" or "seconds", then else if (unit == "minutes"sv || unit == "seconds"sv) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 48133a3353..5503f173c2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -37,7 +37,7 @@ void DurationFormatConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> DurationFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.DurationFormat"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.DurationFormat"); } // 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat @@ -68,7 +68,7 @@ ThrowCompletionOr<Object*> DurationFormatConstructor::construct(FunctionObject& if (!numbering_system.is_undefined()) { // 7. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (numbering_system.is_undefined() || !Unicode::is_type_identifier(numbering_system.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); } // 8. Let opt be the Record { [[localeMatcher]]: matcher, [[nu]]: numberingSystem }. diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index 9c180474a3..95d9af03d2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -43,7 +43,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format) // 4. If IsValidDurationRecord(record) is false, throw a RangeError exception. if (!is_valid_duration_record(record)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationLikeObject); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationLikeObject); // 5. Let formatted be ? PartitionDurationFormatPattern(df, record). auto formatted = TRY(partition_duration_format_pattern(global_object, *duration_format, record)); @@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts) // 4. If IsValidDurationRecord(record) is false, throw a RangeError exception. if (!is_valid_duration_record(record)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationLikeObject); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationLikeObject); // 5. Let formatted be ? PartitionDurationFormatPattern(df, record). auto formatted = TRY(partition_duration_format_pattern(global_object, *duration_format, record)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp index 8e829afbb6..bd8009c9a2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/Intl.cpp @@ -151,7 +151,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of) // 8. Else, else { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidKey, key); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidKey, key); } // 9. Return CreateArrayFromList( list ). diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 48991142c2..48e01dd6c7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -270,7 +270,7 @@ ThrowCompletionOr<Vector<String>> string_list_from_iterable(GlobalObject& global // ii. If Type(nextValue) is not String, then if (!next_value.is_string()) { // 1. Let error be ThrowCompletion(a newly created TypeError object). - auto error = vm.throw_completion<TypeError>(global_object, ErrorType::NotAString, next_value); + auto error = vm.throw_completion<TypeError>(ErrorType::NotAString, next_value); // 2. Return ? IteratorClose(iteratorRecord, error). return iterator_close(global_object, iterator_record, move(error)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index 448e349e90..ab0bb41aa2 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -39,7 +39,7 @@ void ListFormatConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> ListFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.ListFormat"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.ListFormat"); } // 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat diff --git a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index a242d5e65c..f4d83685e7 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -35,7 +35,7 @@ static ThrowCompletionOr<Optional<String>> get_string_option(GlobalObject& globa return Optional<String> {}; if (validator && !validator(option.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, option, property); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, option, property); return option.as_string().string(); } @@ -51,7 +51,7 @@ static ThrowCompletionOr<String> apply_options_to_tag(GlobalObject& global_objec // 3. If ! IsStructurallyValidLanguageTag(tag) is false, throw a RangeError exception. auto locale_id = is_structurally_valid_language_tag(tag); if (!locale_id.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidLanguageTag, tag); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidLanguageTag, tag); // 4. Let language be ? GetOption(options, "language", "string", undefined, undefined). // 5. If language is not undefined, then @@ -240,7 +240,7 @@ void LocaleConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> LocaleConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.Locale"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.Locale"); } // 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale @@ -268,7 +268,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ // 7. If Type(tag) is not String or Object, throw a TypeError exception. if (!tag_value.is_string() && !tag_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOrString, "tag"sv); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrString, "tag"sv); // 8. If Type(tag) is Object and tag has an [[InitializedLocale]] internal slot, then if (tag_value.is_object() && is<Locale>(tag_value.as_object())) { diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index 71d0a4210d..608490ac0a 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -1726,9 +1726,9 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pat // 1. If x is NaN or y is NaN, throw a RangeError exception. if (start.is_nan()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaN, "start"sv); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaN, "start"sv); if (end.is_nan()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaN, "end"sv); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaN, "end"sv); // 2. Let result be a new empty List. Vector<PatternPartitionWithSource> result; diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index 5f31c5a220..2dd50ff4f0 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -107,7 +107,7 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(GlobalObject& global_o if (!numbering_system.is_undefined()) { // a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(numbering_system.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); // 8. Set opt.[[nu]] to numberingSystem. opt.nu = numbering_system.as_string().string(); @@ -178,15 +178,15 @@ ThrowCompletionOr<NumberFormat*> initialize_number_format(GlobalObject& global_o static constexpr auto sanctioned_rounding_increments = AK::Array { 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 }; if (!sanctioned_rounding_increments.span().contains_slow(*rounding_increment)) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidRoundingIncrement, *rounding_increment); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidRoundingIncrement, *rounding_increment); // 23. If roundingIncrement is not 1 and numberFormat.[[RoundingType]] is not fractionDigits, throw a TypeError exception. if ((rounding_increment != 1) && (number_format.rounding_type() != NumberFormatBase::RoundingType::FractionDigits)) - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlInvalidRoundingIncrementForRoundingType, *rounding_increment, number_format.rounding_type_string()); + return vm.throw_completion<TypeError>(ErrorType::IntlInvalidRoundingIncrementForRoundingType, *rounding_increment, number_format.rounding_type_string()); // 24. If roundingIncrement is not 1 and numberFormat.[[MaximumFractionDigits]] is not equal to numberFormat.[[MinimumFractionDigits]], throw a RangeError exception. if ((rounding_increment != 1) && (number_format.max_fraction_digits() != number_format.min_fraction_digits())) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidRoundingIncrementForFractionDigits, *rounding_increment); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidRoundingIncrementForFractionDigits, *rounding_increment); // 25. Set numberFormat.[[RoundingIncrement]] to roundingIncrement. number_format.set_rounding_increment(*rounding_increment); @@ -335,7 +335,7 @@ ThrowCompletionOr<void> set_number_format_digit_options(GlobalObject& global_obj max_digits = max(default_max_fraction_digits, *min_digits); // v. Else if mnfd is greater than mxfd, throw a RangeError exception. else if (*min_digits > *max_digits) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlMinimumExceedsMaximum, *min_digits, *max_digits); + return vm.throw_completion<RangeError>(ErrorType::IntlMinimumExceedsMaximum, *min_digits, *max_digits); // vi. Set intlObj.[[MinimumFractionDigits]] to mnfd. intl_object.set_min_fraction_digits(*min_digits); @@ -419,12 +419,12 @@ ThrowCompletionOr<void> set_number_format_unit_options(GlobalObject& global_obje if (currency.is_undefined()) { // a. If style is "currency", throw a TypeError exception. if (intl_object.style() == NumberFormat::Style::Currency) - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlOptionUndefined, "currency"sv, "style"sv, style); + return vm.throw_completion<TypeError>(ErrorType::IntlOptionUndefined, "currency"sv, "style"sv, style); } // 7. Else, // a. If ! IsWellFormedCurrencyCode(currency) is false, throw a RangeError exception. else if (!is_well_formed_currency_code(currency.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, currency, "currency"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, currency, "currency"sv); // 8. Let currencyDisplay be ? GetOption(options, "currencyDisplay", "string", ยซ "code", "symbol", "narrowSymbol", "name" ยป, "symbol"). auto currency_display = TRY(get_option(global_object, options, vm.names.currencyDisplay, OptionType::String, { "code"sv, "symbol"sv, "narrowSymbol"sv, "name"sv }, "symbol"sv)); @@ -439,12 +439,12 @@ ThrowCompletionOr<void> set_number_format_unit_options(GlobalObject& global_obje if (unit.is_undefined()) { // a. If style is "unit", throw a TypeError exception. if (intl_object.style() == NumberFormat::Style::Unit) - return vm.throw_completion<TypeError>(global_object, ErrorType::IntlOptionUndefined, "unit"sv, "style"sv, style); + return vm.throw_completion<TypeError>(ErrorType::IntlOptionUndefined, "unit"sv, "style"sv, style); } // 12. Else, // a. If ! IsWellFormedUnitIdentifier(unit) is false, throw a RangeError exception. else if (!is_well_formed_unit_identifier(unit.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, unit, "unit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, unit, "unit"sv); // 13. Let unitDisplay be ? GetOption(options, "unitDisplay", "string", ยซ "short", "narrow", "long" ยป, "short"). auto unit_display = TRY(get_option(global_object, options, vm.names.unitDisplay, OptionType::String, { "short"sv, "narrow"sv, "long"sv }, "short"sv)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index 70b8cdef48..bfb7691920 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -92,9 +92,9 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range) // 3. If start is undefined or end is undefined, throw a TypeError exception. if (start.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "start"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "start"sv); if (end.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "end"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "end"sv); // 4. Let x be ? ToIntlMathematicalValue(start). auto x = TRY(to_intl_mathematical_value(global_object, start)); @@ -119,9 +119,9 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range_to_parts) // 3. If start is undefined or end is undefined, throw a TypeError exception. if (start.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "start"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "start"sv); if (end.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "end"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "end"sv); // 4. Let x be ? ToIntlMathematicalValue(start). auto x = TRY(to_intl_mathematical_value(global_object, start)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp index e7657e80d0..b264530188 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRules.cpp @@ -148,9 +148,9 @@ ThrowCompletionOr<Unicode::PluralCategory> resolve_plural_range(GlobalObject& gl // 5. If x is NaN or y is NaN, throw a RangeError exception. if (start.is_nan()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaN, "start"sv); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaN, "start"sv); if (end.is_nan()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaN, "end"sv); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaN, "end"sv); // 6. Let xp be ! ResolvePlural(pluralRules, x). auto start_plurality = resolve_plural(plural_rules, start); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp index b2fb5c76a3..f6a87011d5 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp @@ -39,7 +39,7 @@ void PluralRulesConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> PluralRulesConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.PluralRules"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.PluralRules"); } // 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules diff --git a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index 25b556027f..07b3115d50 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -60,9 +60,9 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range) // 3. If start is undefined or end is undefined, throw a TypeError exception. if (start.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "start"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "start"sv); if (end.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsUndefined, "end"sv); + return vm.throw_completion<TypeError>(ErrorType::IsUndefined, "end"sv); // 4. Let x be ? ToNumber(start). auto x = TRY(start.to_number(global_object)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp index cf0e50d88f..2d131a495c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp @@ -89,7 +89,7 @@ ThrowCompletionOr<Unicode::TimeUnit> singular_relative_time_unit(GlobalObject& g // 11. Return unit. if (auto time_unit = Unicode::time_unit_from_string(unit); time_unit.has_value()) return *time_unit; - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlInvalidUnit, unit); + return vm.throw_completion<RangeError>(ErrorType::IntlInvalidUnit, unit); } // 17.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-PartitionRelativeTimePattern @@ -103,7 +103,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithUnit>> partition_relative_time_patt // 4. If value is NaN, +โ๐ฝ, or -โ๐ฝ, throw a RangeError exception. if (!Value(value).is_finite_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaNOrInfinity); + return vm.throw_completion<RangeError>(ErrorType::IntlNumberIsNaNOrInfinity); // 5. Let unit be ? SingularRelativeTimeUnit(unit). auto time_unit = TRY(singular_relative_time_unit(global_object, unit)); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index 9514293d99..9e322d1d9c 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -42,7 +42,7 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> RelativeTimeFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.RelativeTimeFormat"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.RelativeTimeFormat"); } // 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat @@ -103,7 +103,7 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(GlobalObj if (!numbering_system.is_undefined()) { // a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. if (!Unicode::is_type_identifier(numbering_system.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, numbering_system, "numberingSystem"sv); // 8. Set opt.[[nu]] to numberingSystem. opt.nu = numbering_system.as_string().string(); diff --git a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index 47871f440e..2e631a58c0 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -38,7 +38,7 @@ void SegmenterConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> SegmenterConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. - return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.Segmenter"); + return vm().throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Intl.Segmenter"); } // 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter diff --git a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp index 9d14a77bde..9681871b34 100644 --- a/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/IteratorOperations.cpp @@ -50,14 +50,14 @@ ThrowCompletionOr<Iterator> get_iterator(GlobalObject& global_object, Value valu // NOTE: Additional type check to produce a better error message than Call(). if (!method->is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotIterable, value.to_string_without_side_effects()); // 3. Let iterator be ? Call(method, obj). auto iterator = TRY(call(global_object, *method, value)); // 4. If Type(iterator) is not Object, throw a TypeError exception. if (!iterator.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotIterable, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotIterable, value.to_string_without_side_effects()); // 5. Let nextMethod be ? GetV(iterator, "next"). auto next_method = TRY(iterator.get(global_object, vm.names.next)); @@ -87,7 +87,7 @@ ThrowCompletionOr<Object*> iterator_next(GlobalObject& global_object, Iterator c // 3. If Type(result) is not Object, throw a TypeError exception. if (!result.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IterableNextBadReturn); + return vm.throw_completion<TypeError>(ErrorType::IterableNextBadReturn); // 4. Return result. return &result.as_object(); @@ -175,7 +175,7 @@ static Completion iterator_close_impl(GlobalObject& global_object, Iterator cons // 7. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. if (!inner_result.value().is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IterableReturnBadReturn); + return vm.throw_completion<TypeError>(ErrorType::IterableReturnBadReturn); // 8. Return ? completion. return completion; diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp index e11291d05f..ef60a2e792 100644 --- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp @@ -200,7 +200,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_property(GlobalObject& glob // 10. If Type(value) is BigInt, throw a TypeError exception. if (value.is_bigint()) - return vm.throw_completion<TypeError>(global_object, ErrorType::JsonBigInt); + return vm.throw_completion<TypeError>(ErrorType::JsonBigInt); // 11. If Type(value) is Object and IsCallable(value) is false, then if (value.is_object() && !value.is_function()) { @@ -224,7 +224,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(GlobalObject& global { auto& vm = global_object.vm(); if (state.seen_objects.contains(&object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::JsonCircular); + return vm.throw_completion<TypeError>(ErrorType::JsonCircular); state.seen_objects.set(&object); String previous_indent = state.indent; @@ -293,7 +293,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(GlobalObject& global_ { auto& vm = global_object.vm(); if (state.seen_objects.contains(&object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::JsonCircular); + return vm.throw_completion<TypeError>(ErrorType::JsonCircular); state.seen_objects.set(&object); String previous_indent = state.indent; @@ -401,7 +401,7 @@ JS_DEFINE_NATIVE_FUNCTION(JSONObject::parse) auto json = JsonValue::from_string(string); if (json.is_error()) - return vm.throw_completion<SyntaxError>(global_object, ErrorType::JsonMalformed); + return vm.throw_completion<SyntaxError>(ErrorType::JsonMalformed); Value unfiltered = parse_json_value(global_object, json.value()); if (reviver.is_function()) { auto* root = Object::create(realm, global_object.object_prototype()); diff --git a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp index c319c38079..45b414d9c1 100644 --- a/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapConstructor.cpp @@ -35,7 +35,7 @@ void MapConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> MapConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.Map); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.Map); } // 24.1.1.1 Map ( [ iterable ] ), https://tc39.es/ecma262/#sec-map-iterable @@ -51,11 +51,11 @@ ThrowCompletionOr<Object*> MapConstructor::construct(FunctionObject& new_target) auto adder = TRY(map->get(vm.names.set)); if (!adder.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, "'set' property of Map"); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, "'set' property of Map"); (void)TRY(get_iterator_values(global_object, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); diff --git a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp index 50dc9a17f2..eb053c80e8 100644 --- a/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/MapPrototype.cpp @@ -69,7 +69,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each) { auto* map = TRY(typed_this_object(global_object)); if (!vm.argument(0).is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects()); auto this_value = vm.this_value(global_object); for (auto& entry : *map) TRY(call(global_object, vm.argument(0).as_function(), vm.argument(1), entry.value, entry.key, this_value)); diff --git a/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.cpp index 4135a13124..8620c15fd2 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleEnvironment.cpp @@ -36,7 +36,7 @@ ThrowCompletionOr<Value> ModuleEnvironment::get_binding_value(GlobalObject& glob // c. If targetEnv is empty, throw a ReferenceError exception. if (!target_env) - return vm().throw_completion<ReferenceError>(global_object, ErrorType::ModuleNoEnvironment); + return vm().throw_completion<ReferenceError>(ErrorType::ModuleNoEnvironment); // d. Return ? targetEnv.GetBindingValue(N2, true). return target_env->get_binding_value(global_object, indirect_binding->binding_name, true); diff --git a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp index 5078b4604a..a54ebbd9bb 100644 --- a/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ModuleNamespaceObject.cpp @@ -172,7 +172,7 @@ ThrowCompletionOr<Value> ModuleNamespaceObject::internal_get(PropertyKey const& // 11. If targetEnv is empty, throw a ReferenceError exception. if (!target_environment) - return vm().throw_completion<ReferenceError>(global_object(), ErrorType::ModuleNoEnvironment); + return vm().throw_completion<ReferenceError>(ErrorType::ModuleNoEnvironment); // 12. Return ? targetEnv.GetBindingValue(binding.[[BindingName]], true). return target_environment->get_binding_value(global_object(), binding.export_name, true); diff --git a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp index cf7436c0ec..5415e12a5c 100644 --- a/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -119,7 +119,7 @@ static ThrowCompletionOr<Value> this_number_value(GlobalObject& global_object, V auto& vm = global_object.vm(); // 3. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Number"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Number"); } // 21.1.3.2 Number.prototype.toExponential ( fractionDigits ), https://tc39.es/ecma262/#sec-number.prototype.toexponential @@ -142,7 +142,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_exponential) // 5. If f < 0 or f > 100, throw a RangeError exception. if (fraction_digits < 0 || fraction_digits > 100) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidFractionDigits); + return vm.throw_completion<RangeError>(ErrorType::InvalidFractionDigits); // 6. Set x to โ(x). auto number = number_value.as_double(); @@ -255,11 +255,11 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) // 4. If f is not finite, throw a RangeError exception. if (!Value(fraction_digits).is_finite_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidFractionDigits); + return vm.throw_completion<RangeError>(ErrorType::InvalidFractionDigits); // 5. If f < 0 or f > 100, throw a RangeError exception. if (fraction_digits < 0 || fraction_digits > 100) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidFractionDigits); + return vm.throw_completion<RangeError>(ErrorType::InvalidFractionDigits); // 6. If x is not finite, return Number::toString(x). if (!number_value.is_finite_number()) @@ -356,7 +356,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_precision) // 5. If p < 1 or p > 100, throw a RangeError exception. if ((precision < 1) || (precision > 100)) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidPrecision); + return vm.throw_completion<RangeError>(ErrorType::InvalidPrecision); // 6. Set x to โ(x). auto number = number_value.as_double(); @@ -484,7 +484,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string) // 4. If radixMV < 2 or radixMV > 36, throw a RangeError exception. if (radix_mv < 2 || radix_mv > 36) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidRadix); + return vm.throw_completion<RangeError>(ErrorType::InvalidRadix); // 5. If radixMV = 10, return ! ToString(x). if (radix_mv == 10) diff --git a/Userland/Libraries/LibJS/Runtime/Object.cpp b/Userland/Libraries/LibJS/Runtime/Object.cpp index 0193767ca9..72f61439b3 100644 --- a/Userland/Libraries/LibJS/Runtime/Object.cpp +++ b/Userland/Libraries/LibJS/Runtime/Object.cpp @@ -109,7 +109,7 @@ ThrowCompletionOr<void> Object::set(PropertyKey const& property_key, Value value // 2. If success is false and Throw is true, throw a TypeError exception. if (!success && throw_exceptions == ShouldThrowExceptions::Yes) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object(), ErrorType::ObjectSetReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectSetReturnedFalse); } // 3. Return unused. @@ -170,7 +170,7 @@ ThrowCompletionOr<bool> Object::create_data_property_or_throw(PropertyKey const& // 2. If success is false, throw a TypeError exception. if (!success) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object(), ErrorType::ObjectDefineOwnPropertyReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectDefineOwnPropertyReturnedFalse); } // 3. Return success. @@ -207,7 +207,7 @@ ThrowCompletionOr<void> Object::define_property_or_throw(PropertyKey const& prop // 2. If success is false, throw a TypeError exception. if (!success) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object(), ErrorType::ObjectDefineOwnPropertyReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectDefineOwnPropertyReturnedFalse); } // 3. Return unused. @@ -227,7 +227,7 @@ ThrowCompletionOr<void> Object::delete_property_or_throw(PropertyKey const& prop // 2. If success is false, throw a TypeError exception. if (!success) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object(), ErrorType::ObjectDeleteReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectDeleteReturnedFalse); } // 3. Return unused. @@ -462,15 +462,17 @@ PrivateElement* Object::private_element_find(PrivateName const& name) // 7.3.28 PrivateFieldAdd ( O, P, value ), https://tc39.es/ecma262/#sec-privatefieldadd ThrowCompletionOr<void> Object::private_field_add(PrivateName const& name, Value value) { + auto& vm = this->vm(); + // 1. If the host is a web browser, then // a. Perform ? HostEnsureCanAddPrivateElement(O). // NOTE: Since LibJS has no way of knowing whether it is in a browser we just always call the hook. - TRY(vm().host_ensure_can_add_private_element(*this)); + TRY(vm.host_ensure_can_add_private_element(*this)); // 2. Let entry be PrivateElementFind(O, P). // 3. If entry is not empty, throw a TypeError exception. if (auto* entry = private_element_find(name); entry) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldAlreadyDeclared, name.description); + return vm.throw_completion<TypeError>(ErrorType::PrivateFieldAlreadyDeclared, name.description); if (!m_private_elements) m_private_elements = make<Vector<PrivateElement>>(); @@ -485,18 +487,20 @@ ThrowCompletionOr<void> Object::private_field_add(PrivateName const& name, Value // 7.3.29 PrivateMethodOrAccessorAdd ( O, method ), https://tc39.es/ecma262/#sec-privatemethodoraccessoradd ThrowCompletionOr<void> Object::private_method_or_accessor_add(PrivateElement element) { + auto& vm = this->vm(); + // 1. Assert: method.[[Kind]] is either method or accessor. VERIFY(element.kind == PrivateElement::Kind::Method || element.kind == PrivateElement::Kind::Accessor); // 2. If the host is a web browser, then // a. Perform ? HostEnsureCanAddPrivateElement(O). // NOTE: Since LibJS has no way of knowing whether it is in a browser we just always call the hook. - TRY(vm().host_ensure_can_add_private_element(*this)); + TRY(vm.host_ensure_can_add_private_element(*this)); // 3. Let entry be PrivateElementFind(O, method.[[Key]]). // 4. If entry is not empty, throw a TypeError exception. if (auto* entry = private_element_find(element.key); entry) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldAlreadyDeclared, element.key.description); + return vm.throw_completion<TypeError>(ErrorType::PrivateFieldAlreadyDeclared, element.key.description); if (!m_private_elements) m_private_elements = make<Vector<PrivateElement>>(); @@ -513,7 +517,7 @@ ThrowCompletionOr<Value> Object::private_get(PrivateName const& name) { auto* entry = private_element_find(name); if (!entry) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldDoesNotExistOnObject, name.description); + return vm().throw_completion<TypeError>(ErrorType::PrivateFieldDoesNotExistOnObject, name.description); auto& value = entry->value; @@ -523,7 +527,7 @@ ThrowCompletionOr<Value> Object::private_get(PrivateName const& name) VERIFY(value.is_accessor()); auto* getter = value.as_accessor().getter(); if (!getter) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldGetAccessorWithoutGetter, name.description); + return vm().throw_completion<TypeError>(ErrorType::PrivateFieldGetAccessorWithoutGetter, name.description); // 8. Return ? Call(getter, Receiver). return TRY(call(global_object(), *getter, this)); @@ -534,13 +538,13 @@ ThrowCompletionOr<void> Object::private_set(PrivateName const& name, Value value { auto* entry = private_element_find(name); if (!entry) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldDoesNotExistOnObject, name.description); + return vm().throw_completion<TypeError>(ErrorType::PrivateFieldDoesNotExistOnObject, name.description); if (entry->kind == PrivateElement::Kind::Field) { entry->value = value; return {}; } else if (entry->kind == PrivateElement::Kind::Method) { - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldSetMethod, name.description); + return vm().throw_completion<TypeError>(ErrorType::PrivateFieldSetMethod, name.description); } VERIFY(entry->kind == PrivateElement::Kind::Accessor); @@ -549,7 +553,7 @@ ThrowCompletionOr<void> Object::private_set(PrivateName const& name, Value value VERIFY(accessor.is_accessor()); auto* setter = accessor.as_accessor().setter(); if (!setter) - return vm().throw_completion<TypeError>(global_object(), ErrorType::PrivateFieldSetAccessorWithoutSetter, name.description); + return vm().throw_completion<TypeError>(ErrorType::PrivateFieldSetAccessorWithoutSetter, name.description); TRY(call(global_object(), *setter, this, value)); return {}; @@ -1259,7 +1263,7 @@ ThrowCompletionOr<Value> Object::ordinary_to_primitive(Value::PreferredType pref } // 4. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::Convert, "object", preferred_type == Value::PreferredType::String ? "string" : "number"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "object", preferred_type == Value::PreferredType::String ? "string" : "number"); } } diff --git a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp index 2f0bf8d90a..a5ff79db16 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectConstructor.cpp @@ -148,7 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::set_prototype_of) // 2. If Type(proto) is neither Object nor Null, throw a TypeError exception. if (!proto.is_object() && !proto.is_null()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectPrototypeWrongType); + return vm.throw_completion<TypeError>(ErrorType::ObjectPrototypeWrongType); // 3. If Type(O) is not Object, return O. if (!object.is_object()) @@ -160,7 +160,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::set_prototype_of) // 5. If status is false, throw a TypeError exception. if (!status) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectSetPrototypeOfReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectSetPrototypeOfReturnedFalse); } // 6. Return O. @@ -203,7 +203,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::prevent_extensions) auto status = TRY(argument.as_object().internal_prevent_extensions()); if (!status) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectPreventExtensionsReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectPreventExtensionsReturnedFalse); } return argument; } @@ -216,7 +216,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::freeze) return argument; auto status = TRY(argument.as_object().set_integrity_level(Object::IntegrityLevel::Frozen)); if (!status) - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectFreezeFailed); + return vm.throw_completion<TypeError>(ErrorType::ObjectFreezeFailed); return argument; } @@ -230,7 +230,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::from_entries) (void)TRY(get_iterator_values(global_object, iterable, [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); @@ -252,7 +252,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::seal) return argument; auto status = TRY(argument.as_object().set_integrity_level(Object::IntegrityLevel::Sealed)); if (!status) - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectSealFailed); + return vm.throw_completion<TypeError>(ErrorType::ObjectSealFailed); return argument; } @@ -302,7 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::get_own_property_descriptors) JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_property) { if (!vm.argument(0).is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, vm.argument(0).to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, vm.argument(0).to_string_without_side_effects()); auto key = TRY(vm.argument(1).to_property_key(global_object)); auto descriptor = TRY(to_property_descriptor(global_object, vm.argument(2))); TRY(vm.argument(0).as_object().define_property_or_throw(key, descriptor)); @@ -317,7 +317,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::define_properties) // 1. If Type(O) is not Object, throw a TypeError exception. if (!object.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, "Object argument"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, "Object argument"); // 2. Return ? ObjectDefineProperties(O, Properties). return TRY(object.as_object().define_properties(properties)); @@ -369,7 +369,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectConstructor::create) // 1. If Type(O) is neither Object nor Null, throw a TypeError exception. if (!proto.is_object() && !proto.is_null()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectPrototypeWrongType); + return vm.throw_completion<TypeError>(ErrorType::ObjectPrototypeWrongType); // 2. Let obj be OrdinaryObjectCreate(O). auto* object = Object::create(realm, proto.is_null() ? nullptr : &proto.as_object()); diff --git a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp index 3fa519af7c..f629b70eea 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectEnvironment.cpp @@ -88,7 +88,7 @@ ThrowCompletionOr<void> ObjectEnvironment::initialize_binding(GlobalObject& glob } // 9.1.1.2.5 SetMutableBinding ( N, V, S ), https://tc39.es/ecma262/#sec-object-environment-records-setmutablebinding-n-v-s -ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject& global_object, FlyString const& name, Value value, bool strict) +ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject&, FlyString const& name, Value value, bool strict) { auto& vm = this->vm(); @@ -98,7 +98,7 @@ ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject& glo // 3. If stillExists is false and S is true, throw a ReferenceError exception. if (!still_exists && strict) - return vm.throw_completion<ReferenceError>(global_object, ErrorType::UnknownIdentifier, name); + return vm.throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, name); // 4. Perform ? Set(bindingObject, N, V, S). auto result_or_error = m_binding_object.set(name, value, strict ? Object::ShouldThrowExceptions::Yes : Object::ShouldThrowExceptions::No); @@ -111,7 +111,7 @@ ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject& glo return result_or_error.release_error(); auto property = property_or_error.release_value(); if (property.has_value() && !property->writable.value_or(true)) { - return vm.throw_completion<TypeError>(global_object, ErrorType::DescWriteNonWritable, name); + return vm.throw_completion<TypeError>(ErrorType::DescWriteNonWritable, name); } } @@ -123,7 +123,7 @@ ThrowCompletionOr<void> ObjectEnvironment::set_mutable_binding(GlobalObject& glo } // 9.1.1.2.6 GetBindingValue ( N, S ), https://tc39.es/ecma262/#sec-object-environment-records-getbindingvalue-n-s -ThrowCompletionOr<Value> ObjectEnvironment::get_binding_value(GlobalObject& global_object, FlyString const& name, bool strict) +ThrowCompletionOr<Value> ObjectEnvironment::get_binding_value(GlobalObject&, FlyString const& name, bool strict) { auto& vm = this->vm(); @@ -136,7 +136,7 @@ ThrowCompletionOr<Value> ObjectEnvironment::get_binding_value(GlobalObject& glob // a. If S is false, return undefined; otherwise throw a ReferenceError exception. if (!strict) return js_undefined(); - return vm.throw_completion<ReferenceError>(global_object, ErrorType::UnknownIdentifier, name); + return vm.throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, name); } // 4. Return ? Get(bindingObject, N). diff --git a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp index 19662c1dd1..56b811e4b9 100644 --- a/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ObjectPrototype.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -185,7 +185,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::define_getter) auto getter = vm.argument(1); if (!getter.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, getter.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, getter.to_string_without_side_effects()); auto descriptor = PropertyDescriptor { .get = &getter.as_function(), .enumerable = true, .configurable = true }; @@ -203,7 +203,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::define_setter) auto setter = vm.argument(1); if (!setter.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, setter.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, setter.to_string_without_side_effects()); auto descriptor = PropertyDescriptor { .set = &setter.as_function(), .enumerable = true, .configurable = true }; @@ -276,7 +276,7 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::proto_setter) auto status = TRY(object.as_object().internal_set_prototype_of(proto.is_object() ? &proto.as_object() : nullptr)); if (!status) { // FIXME: Improve/contextualize error message - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectSetPrototypeOfReturnedFalse); + return vm.throw_completion<TypeError>(ErrorType::ObjectSetPrototypeOfReturnedFalse); } return js_undefined(); } diff --git a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp index f0e1ad5ade..3026aba2f9 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseConstructor.cpp @@ -31,7 +31,7 @@ static ThrowCompletionOr<Value> get_promise_resolve(GlobalObject& global_object, // 2. If IsCallable(promiseResolve) is false, throw a TypeError exception. if (!promise_resolve.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, promise_resolve.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, promise_resolve.to_string_without_side_effects()); // 3. Return promiseResolve. return promise_resolve; @@ -279,7 +279,7 @@ ThrowCompletionOr<Value> PromiseConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.Promise); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.Promise); } // 27.2.3.1 Promise ( executor ), https://tc39.es/ecma262/#sec-promise-executor @@ -292,7 +292,7 @@ ThrowCompletionOr<Object*> PromiseConstructor::construct(FunctionObject& new_tar // 2. If IsCallable(executor) is false, throw a TypeError exception. if (!executor.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::PromiseExecutorNotAFunction); + return vm.throw_completion<TypeError>(ErrorType::PromiseExecutorNotAFunction); // 3. Let promise be ? OrdinaryCreateFromConstructor(NewTarget, "%Promise.prototype%", ยซ [[PromiseState]], [[PromiseResult]], [[PromiseFulfillReactions]], [[PromiseRejectReactions]], [[PromiseIsHandled]] ยป). // 4. Set promise.[[PromiseState]] to pending. @@ -481,7 +481,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromiseConstructor::resolve) // 2. If Type(C) is not Object, throw a TypeError exception. if (!constructor.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, constructor.to_string_without_side_effects()); // 3. Return ? PromiseResolve(C, x). return TRY(promise_resolve(global_object, constructor.as_object(), value)); diff --git a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp index 68a29b0f3e..413710abf2 100644 --- a/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromisePrototype.cpp @@ -79,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::finally) // 2. If Type(promise) is not Object, throw a TypeError exception. if (!promise.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, promise.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, promise.to_string_without_side_effects()); // 3. Let C be ? SpeciesConstructor(promise, %Promise%). auto* constructor = TRY(species_constructor(global_object, promise.as_object(), *global_object.promise_constructor())); diff --git a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp index beadbce5b8..3a41dc5b5c 100644 --- a/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp +++ b/Userland/Libraries/LibJS/Runtime/PromiseReaction.cpp @@ -19,7 +19,7 @@ ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global // 1. If IsConstructor(C) is false, throw a TypeError exception. if (!constructor.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); // 2. NOTE: C is assumed to be a constructor function that supports the parameter conventions of the Promise constructor (see 27.2.3.1). @@ -32,18 +32,18 @@ ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global } promise_capability_functions; // 4. Let executorClosure be a new Abstract Closure with parameters (resolve, reject) that captures promiseCapability and performs the following steps when called: - auto executor_closure = [&promise_capability_functions](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> { + auto executor_closure = [&promise_capability_functions](auto& vm, auto&) -> ThrowCompletionOr<Value> { auto resolve = vm.argument(0); auto reject = vm.argument(1); // No idea what other engines say here. // a. If promiseCapability.[[Resolve]] is not undefined, throw a TypeError exception. if (!promise_capability_functions.resolve.is_undefined()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::GetCapabilitiesExecutorCalledMultipleTimes); + return vm.template throw_completion<TypeError>(ErrorType::GetCapabilitiesExecutorCalledMultipleTimes); // b. If promiseCapability.[[Reject]] is not undefined, throw a TypeError exception. if (!promise_capability_functions.reject.is_undefined()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::GetCapabilitiesExecutorCalledMultipleTimes); + return vm.template throw_completion<TypeError>(ErrorType::GetCapabilitiesExecutorCalledMultipleTimes); // c. Set promiseCapability.[[Resolve]] to resolve. promise_capability_functions.resolve = resolve; @@ -63,11 +63,11 @@ ThrowCompletionOr<PromiseCapability> new_promise_capability(GlobalObject& global // 7. If IsCallable(promiseCapability.[[Resolve]]) is false, throw a TypeError exception. if (!promise_capability_functions.resolve.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, promise_capability_functions.resolve.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, promise_capability_functions.resolve.to_string_without_side_effects()); // 8. If IsCallable(promiseCapability.[[Reject]]) is false, throw a TypeError exception. if (!promise_capability_functions.reject.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, promise_capability_functions.reject.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, promise_capability_functions.reject.to_string_without_side_effects()); // 9. Set promiseCapability.[[Promise]] to promise. // 10. Return promiseCapability. diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp index e5130e90b0..b471116277 100644 --- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp +++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp @@ -94,7 +94,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa // 1. If Type(Obj) is not Object, throw a TypeError exception. if (!argument.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, argument.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, argument.to_string_without_side_effects()); auto& object = argument.as_object(); @@ -159,7 +159,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa // b. If IsCallable(getter) is false and getter is not undefined, throw a TypeError exception. if (!getter.is_function() && !getter.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorBadField, "get"); + return vm.throw_completion<TypeError>(ErrorType::AccessorBadField, "get"); // c. Set desc.[[Get]] to getter. descriptor.get = getter.is_function() ? &getter.as_function() : nullptr; @@ -175,7 +175,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa // b. If IsCallable(setter) is false and setter is not undefined, throw a TypeError exception. if (!setter.is_function() && !setter.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorBadField, "set"); + return vm.throw_completion<TypeError>(ErrorType::AccessorBadField, "set"); // c. Set desc.[[Set]] to setter. descriptor.set = setter.is_function() ? &setter.as_function() : nullptr; @@ -185,7 +185,7 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa if (descriptor.get.has_value() || descriptor.set.has_value()) { // a. If desc has a [[Value]] field or desc has a [[Writable]] field, throw a TypeError exception. if (descriptor.value.has_value() || descriptor.writable.has_value()) - return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorValueOrWritable); + return vm.throw_completion<TypeError>(ErrorType::AccessorValueOrWritable); } // 16. Return desc. diff --git a/Userland/Libraries/LibJS/Runtime/PrototypeObject.h b/Userland/Libraries/LibJS/Runtime/PrototypeObject.h index da865dbfff..e88afea667 100644 --- a/Userland/Libraries/LibJS/Runtime/PrototypeObject.h +++ b/Userland/Libraries/LibJS/Runtime/PrototypeObject.h @@ -31,7 +31,7 @@ public: auto& vm = global_object.vm(); auto this_value = vm.this_value(global_object); if (!this_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, this_value); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, this_value); return &this_value.as_object(); } @@ -41,7 +41,7 @@ public: auto& vm = global_object.vm(); auto* this_object = TRY(vm.this_value(global_object).to_object(global_object)); if (!is<ObjectType>(this_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, PrototypeType::display_name()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, PrototypeType::display_name()); return static_cast<ObjectType*>(this_object); } @@ -51,7 +51,7 @@ public: auto& vm = global_object.vm(); auto this_value = vm.this_value(global_object); if (!this_value.is_object() || !is<ObjectType>(this_value.as_object())) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, PrototypeType::display_name()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, PrototypeType::display_name()); return static_cast<ObjectType*>(&this_value.as_object()); } diff --git a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp index 2d4f75927c..3a7ba4fe00 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyConstructor.cpp @@ -19,9 +19,9 @@ static ThrowCompletionOr<ProxyObject*> proxy_create(GlobalObject& global_object, auto& vm = global_object.vm(); auto& realm = *global_object.associated_realm(); if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "target", target.to_string_without_side_effects()); if (!handler.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ProxyConstructorBadType, "handler", handler.to_string_without_side_effects()); return ProxyObject::create(realm, target.as_object(), handler.as_object()); } @@ -44,7 +44,7 @@ void ProxyConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> ProxyConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.Proxy); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.Proxy); } // 28.2.1.1 Proxy ( target, handler ), https://tc39.es/ecma262/#sec-proxy-target-handler diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index ae51a7d2ae..d61f0ccfe3 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -50,7 +50,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_get_prototype_of() const // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -69,7 +69,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_get_prototype_of() const // 8. If Type(handlerProto) is neither Object nor Null, throw a TypeError exception. if (!handler_proto.is_object() && !handler_proto.is_null()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetPrototypeOfReturn); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetPrototypeOfReturn); // 9. Let extensibleTarget be ? IsExtensible(target). auto extensible_target = TRY(m_target.is_extensible()); @@ -83,7 +83,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_get_prototype_of() const // 12. If SameValue(handlerProto, targetProto) is false, throw a TypeError exception. if (!same_value(handler_proto, target_proto)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetPrototypeOfNonExtensible); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetPrototypeOfNonExtensible); // 13. Return handlerProto. return handler_proto.is_null() ? nullptr : &handler_proto.as_object(); @@ -99,7 +99,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_set_prototype_of(Object* prototype // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -132,7 +132,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_set_prototype_of(Object* prototype // 12. If SameValue(V, targetProto) is false, throw a TypeError exception. if (!same_value(prototype, target_proto)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxySetPrototypeOfNonExtensible); + return vm.throw_completion<TypeError>(ErrorType::ProxySetPrototypeOfNonExtensible); // 13. Return true. return true; @@ -148,7 +148,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_is_extensible() const // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -170,7 +170,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_is_extensible() const // 9. If SameValue(booleanTrapResult, targetResult) is false, throw a TypeError exception. if (trap_result != target_result) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyIsExtensibleReturn); + return vm.throw_completion<TypeError>(ErrorType::ProxyIsExtensibleReturn); // 10. Return booleanTrapResult. return trap_result; @@ -186,7 +186,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_prevent_extensions() // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -210,7 +210,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_prevent_extensions() // b. If extensibleTarget is true, throw a TypeError exception. if (extensible_target) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyPreventExtensionsReturn); + return vm.throw_completion<TypeError>(ErrorType::ProxyPreventExtensionsReturn); } // 9. Return booleanTrapResult. @@ -229,7 +229,7 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -248,7 +248,7 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr // 8. If Type(trapResultObj) is neither Object nor Undefined, throw a TypeError exception. if (!trap_result.is_object() && !trap_result.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorReturn); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorReturn); // 9. Let targetDesc be ? target.[[GetOwnProperty]](P). auto target_descriptor = TRY(m_target.internal_get_own_property(property_key)); @@ -261,14 +261,14 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr // b. If targetDesc.[[Configurable]] is false, throw a TypeError exception. if (!*target_descriptor->configurable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorNonConfigurable); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorNonConfigurable); // c. Let extensibleTarget be ? IsExtensible(target). auto extensible_target = TRY(m_target.is_extensible()); // d. If extensibleTarget is false, throw a TypeError exception. if (!extensible_target) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorUndefinedReturn); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorUndefinedReturn); // e. Return undefined. return Optional<PropertyDescriptor> {}; @@ -288,20 +288,20 @@ ThrowCompletionOr<Optional<PropertyDescriptor>> ProxyObject::internal_get_own_pr // 15. If valid is false, throw a TypeError exception. if (!valid) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorInvalidDescriptor); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorInvalidDescriptor); // 16. If resultDesc.[[Configurable]] is false, then if (!*result_desc.configurable) { // a. If targetDesc is undefined or targetDesc.[[Configurable]] is true, then if (!target_descriptor.has_value() || *target_descriptor->configurable) // i. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorInvalidNonConfig); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorInvalidNonConfig); // b. If resultDesc has a [[Writable]] field and resultDesc.[[Writable]] is false, then if (result_desc.writable.has_value() && !*result_desc.writable) { // i. If targetDesc.[[Writable]] is true, throw a TypeError exception. if (*target_descriptor->writable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetOwnDescriptorNonConfigurableNonWritable); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetOwnDescriptorNonConfigurableNonWritable); } } @@ -321,7 +321,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_define_own_property(PropertyKey co // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -364,27 +364,27 @@ ThrowCompletionOr<bool> ProxyObject::internal_define_own_property(PropertyKey co if (!target_descriptor.has_value()) { // a. If extensibleTarget is false, throw a TypeError exception. if (!extensible_target) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDefinePropNonExtensible); + return vm.throw_completion<TypeError>(ErrorType::ProxyDefinePropNonExtensible); // b. If settingConfigFalse is true, throw a TypeError exception. if (setting_config_false) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDefinePropNonConfigurableNonExisting); + return vm.throw_completion<TypeError>(ErrorType::ProxyDefinePropNonConfigurableNonExisting); } // 15. Else, else { // a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc, targetDesc) is false, throw a TypeError exception. if (!is_compatible_property_descriptor(extensible_target, property_descriptor, target_descriptor)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDefinePropIncompatibleDescriptor); + return vm.throw_completion<TypeError>(ErrorType::ProxyDefinePropIncompatibleDescriptor); // b. If settingConfigFalse is true and targetDesc.[[Configurable]] is true, throw a TypeError exception. if (setting_config_false && *target_descriptor->configurable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDefinePropExistingConfigurable); + return vm.throw_completion<TypeError>(ErrorType::ProxyDefinePropExistingConfigurable); // c. If IsDataDescriptor(targetDesc) is true, targetDesc.[[Configurable]] is false, and targetDesc.[[Writable]] is true, then if (target_descriptor->is_data_descriptor() && !*target_descriptor->configurable && *target_descriptor->writable) { // i. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, throw a TypeError exception. if (property_descriptor.writable.has_value() && !*property_descriptor.writable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDefinePropNonWritable); + return vm.throw_completion<TypeError>(ErrorType::ProxyDefinePropNonWritable); } } @@ -404,7 +404,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_has_property(PropertyKey const& pr // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -430,14 +430,14 @@ ThrowCompletionOr<bool> ProxyObject::internal_has_property(PropertyKey const& pr if (target_descriptor.has_value()) { // i. If targetDesc.[[Configurable]] is false, throw a TypeError exception. if (!*target_descriptor->configurable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyHasExistingNonConfigurable); + return vm.throw_completion<TypeError>(ErrorType::ProxyHasExistingNonConfigurable); // ii. Let extensibleTarget be ? IsExtensible(target). auto extensible_target = TRY(m_target.is_extensible()); // iii. If extensibleTarget is false, throw a TypeError exception. if (!extensible_target) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyHasExistingNonExtensible); + return vm.throw_completion<TypeError>(ErrorType::ProxyHasExistingNonExtensible); } } @@ -460,7 +460,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_get(PropertyKey const& property_k // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -479,7 +479,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_get(PropertyKey const& property_k // // In JS code: `h = {}; p = new Proxy({}, h); h.__proto__ = p; p.foo // or h.foo` if (vm.did_reach_stack_space_limit()) - return vm.throw_completion<InternalError>(global_object, ErrorType::CallStackSizeExceeded); + return vm.throw_completion<InternalError>(ErrorType::CallStackSizeExceeded); // 5. Let trap be ? GetMethod(handler, "get"). auto trap = TRY(Value(&m_handler).get_method(global_object, vm.names.get)); @@ -502,13 +502,13 @@ ThrowCompletionOr<Value> ProxyObject::internal_get(PropertyKey const& property_k if (target_descriptor->is_data_descriptor() && !*target_descriptor->writable) { // i. If SameValue(trapResult, targetDesc.[[Value]]) is false, throw a TypeError exception. if (!same_value(trap_result, *target_descriptor->value)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetImmutableDataProperty); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetImmutableDataProperty); } // b. If IsAccessorDescriptor(targetDesc) is true and targetDesc.[[Get]] is undefined, then if (target_descriptor->is_accessor_descriptor() && !*target_descriptor->get) { // i. If trapResult is not undefined, throw a TypeError exception. if (!trap_result.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyGetNonConfigurableAccessor); + return vm.throw_completion<TypeError>(ErrorType::ProxyGetNonConfigurableAccessor); } } @@ -530,7 +530,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_set(PropertyKey const& property_ke // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -560,13 +560,13 @@ ThrowCompletionOr<bool> ProxyObject::internal_set(PropertyKey const& property_ke if (target_descriptor->is_data_descriptor() && !*target_descriptor->writable) { // i. If SameValue(V, targetDesc.[[Value]]) is false, throw a TypeError exception. if (!same_value(value, *target_descriptor->value)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxySetImmutableDataProperty); + return vm.throw_completion<TypeError>(ErrorType::ProxySetImmutableDataProperty); } // b. If IsAccessorDescriptor(targetDesc) is true, then if (target_descriptor->is_accessor_descriptor()) { // i. If targetDesc.[[Set]] is undefined, throw a TypeError exception. if (!*target_descriptor->set) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxySetNonConfigurableAccessor); + return vm.throw_completion<TypeError>(ErrorType::ProxySetNonConfigurableAccessor); } } @@ -586,7 +586,7 @@ ThrowCompletionOr<bool> ProxyObject::internal_delete(PropertyKey const& property // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -616,14 +616,14 @@ ThrowCompletionOr<bool> ProxyObject::internal_delete(PropertyKey const& property // 11. If targetDesc.[[Configurable]] is false, throw a TypeError exception. if (!*target_descriptor->configurable) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDeleteNonConfigurable); + return vm.throw_completion<TypeError>(ErrorType::ProxyDeleteNonConfigurable); // 12. Let extensibleTarget be ? IsExtensible(target). auto extensible_target = TRY(m_target.is_extensible()); // 13. If extensibleTarget is false, throw a TypeError exception. if (!extensible_target) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyDeleteNonExtensible); + return vm.throw_completion<TypeError>(ErrorType::ProxyDeleteNonExtensible); // 14. Return true. return true; @@ -639,7 +639,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -661,7 +661,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() auto trap_result = TRY(create_list_from_array_like(global_object, trap_result_array, [&](auto value) -> ThrowCompletionOr<void> { auto& vm = global_object.vm(); if (!value.is_string() && !value.is_symbol()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNotStringOrSymbol); + return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNotStringOrSymbol); auto property_key = MUST(value.to_property_key(global_object)); unique_keys.set(property_key, AK::HashSetExistingEntryBehavior::Keep); return {}; @@ -669,7 +669,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() // 9. If trapResult contains any duplicate entries, throw a TypeError exception. if (unique_keys.size() != trap_result.size()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysDuplicates); + return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysDuplicates); // 10. Let extensibleTarget be ? IsExtensible(target). auto extensible_target = TRY(m_target.is_extensible()); @@ -719,7 +719,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() for (auto& key : target_nonconfigurable_keys) { // a. If key is not an element of uncheckedResultKeys, throw a TypeError exception. if (!unchecked_result_keys.contains_slow(key)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysSkippedNonconfigurableProperty, key.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysSkippedNonconfigurableProperty, key.to_string_without_side_effects()); // b. Remove key from uncheckedResultKeys. unchecked_result_keys.remove_first_matching([&](auto& value) { @@ -735,7 +735,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() for (auto& key : target_configurable_keys) { // a. If key is not an element of uncheckedResultKeys, throw a TypeError exception. if (!unchecked_result_keys.contains_slow(key)) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNonExtensibleSkippedProperty, key.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleSkippedProperty, key.to_string_without_side_effects()); // b. Remove key from uncheckedResultKeys. unchecked_result_keys.remove_first_matching([&](auto& value) { @@ -745,7 +745,7 @@ ThrowCompletionOr<MarkedVector<Value>> ProxyObject::internal_own_property_keys() // 22. If uncheckedResultKeys is not empty, throw a TypeError exception. if (!unchecked_result_keys.is_empty()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyOwnPropertyKeysNonExtensibleNewProperty, unchecked_result_keys[0].to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ProxyOwnPropertyKeysNonExtensibleNewProperty, unchecked_result_keys[0].to_string_without_side_effects()); // 23. Return trapResult. return { move(trap_result) }; @@ -763,13 +763,13 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV // According to the spec, the Call() AO may be called with a non-function argument, but // throws before calling [[Call]]() if that's the case. if (!is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, Value(this).to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, Value(this).to_string_without_side_effects()); // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -811,13 +811,13 @@ ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedVector<Value> a // TODO: We should be able to turn this into a VERIFY(), this must be checked at the call site. // According to the spec, the Construct() AO is only ever called with a constructor argument. if (!is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, Value(this).to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, Value(this).to_string_without_side_effects()); // 1. Let handler be O.[[ProxyHandler]]. // 2. If handler is null, throw a TypeError exception. if (m_is_revoked) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); // 3. Assert: Type(handler) is Object. // 4. Let target be O.[[ProxyTarget]]. @@ -840,7 +840,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedVector<Value> a // 10. If Type(newObj) is not Object, throw a TypeError exception. if (!new_object.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyConstructBadReturnType); + return vm.throw_completion<TypeError>(ErrorType::ProxyConstructBadReturnType); // 11. Return newObj. return &new_object.as_object(); diff --git a/Userland/Libraries/LibJS/Runtime/Reference.cpp b/Userland/Libraries/LibJS/Runtime/Reference.cpp index c433c51c93..0547c0de12 100644 --- a/Userland/Libraries/LibJS/Runtime/Reference.cpp +++ b/Userland/Libraries/LibJS/Runtime/Reference.cpp @@ -22,7 +22,7 @@ ThrowCompletionOr<void> Reference::put_value(GlobalObject& global_object, Value // 3. If V is not a Reference Record, throw a ReferenceError exception. if (!is_valid_reference()) - return vm.throw_completion<ReferenceError>(global_object, ErrorType::InvalidLeftHandAssignment); + return vm.throw_completion<ReferenceError>(ErrorType::InvalidLeftHandAssignment); // 4. If IsUnresolvableReference(V) is true, then if (is_unresolvable()) { @@ -54,7 +54,7 @@ ThrowCompletionOr<void> Reference::put_value(GlobalObject& global_object, Value // d. If succeeded is false and V.[[Strict]] is true, throw a TypeError exception. if (!succeeded && m_strict) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReferenceNullishSetProperty, m_name, m_base_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishSetProperty, m_name, m_base_value.to_string_without_side_effects()); // e. Return unused. return {}; @@ -78,9 +78,9 @@ Completion Reference::throw_reference_error(GlobalObject& global_object) const { auto& vm = global_object.vm(); if (!m_name.is_valid()) - return vm.throw_completion<ReferenceError>(global_object, ErrorType::ReferenceUnresolvable); + return vm.throw_completion<ReferenceError>(ErrorType::ReferenceUnresolvable); else - return vm.throw_completion<ReferenceError>(global_object, ErrorType::UnknownIdentifier, m_name.to_string_or_symbol().to_display_string()); + return vm.throw_completion<ReferenceError>(ErrorType::UnknownIdentifier, m_name.to_string_or_symbol().to_display_string()); } // 6.2.4.5 GetValue ( V ), https://tc39.es/ecma262/#sec-getvalue @@ -170,7 +170,7 @@ ThrowCompletionOr<bool> Reference::delete_(GlobalObject& global_object) // b. If IsSuperReference(ref) is true, throw a ReferenceError exception. if (is_super_reference()) - return vm.throw_completion<ReferenceError>(global_object, ErrorType::UnsupportedDeleteSuperProperty); + return vm.throw_completion<ReferenceError>(ErrorType::UnsupportedDeleteSuperProperty); // c. Let baseObj be ! ToObject(ref.[[Base]]). auto* base_obj = MUST(m_base_value.to_object(global_object)); @@ -180,7 +180,7 @@ ThrowCompletionOr<bool> Reference::delete_(GlobalObject& global_object) // e. If deleteStatus is false and ref.[[Strict]] is true, throw a TypeError exception. if (!delete_status && m_strict) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReferenceNullishDeleteProperty, m_name, m_base_value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::ReferenceNullishDeleteProperty, m_name, m_base_value.to_string_without_side_effects()); // f. Return deleteStatus. return delete_status; diff --git a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp index a6b39ffadf..4a4f6ed353 100644 --- a/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ReflectObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::apply) // 1. If IsCallable(target) is false, throw a TypeError exception. if (!target.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, target.to_string_without_side_effects()); // 2. Let args be ? CreateListFromArrayLike(argumentsList). auto args = TRY(create_list_from_array_like(global_object, arguments_list)); @@ -71,14 +71,14 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::construct) // 1. If IsConstructor(target) is false, throw a TypeError exception. if (!target.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, target.to_string_without_side_effects()); // 2. If newTarget is not present, set newTarget to target. if (vm.argument_count() < 3) new_target = target; // 3. Else if IsConstructor(newTarget) is false, throw a TypeError exception. else if (!new_target.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, new_target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, new_target.to_string_without_side_effects()); // 4. Let args be ? CreateListFromArrayLike(argumentsList). auto args = TRY(create_list_from_array_like(global_object, arguments_list)); @@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -116,7 +116,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::delete_property) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -134,7 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -157,7 +157,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_own_property_descriptor) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -176,7 +176,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::get_prototype_of) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Return ? target.[[GetPrototypeOf]](). return TRY(target.as_object().internal_get_prototype_of()); @@ -190,7 +190,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::has) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::is_extensible) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Return ? target.[[IsExtensible]](). return Value(TRY(target.as_object().internal_is_extensible())); @@ -221,7 +221,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::own_keys) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let keys be ? target.[[OwnPropertyKeys]](). auto keys = TRY(target.as_object().internal_own_property_keys()); @@ -237,7 +237,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::prevent_extensions) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Return ? target.[[PreventExtensions]](). return Value(TRY(target.as_object().internal_prevent_extensions())); @@ -253,7 +253,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. Let key be ? ToPropertyKey(propertyKey). auto key = TRY(property_key.to_property_key(global_object)); @@ -276,11 +276,11 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::set_prototype_of) // 1. If Type(target) is not Object, throw a TypeError exception. if (!target.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, target.to_string_without_side_effects()); // 2. If Type(proto) is not Object and proto is not null, throw a TypeError exception. if (!proto.is_object() && !proto.is_null()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ObjectPrototypeWrongType); + return vm.throw_completion<TypeError>(ErrorType::ObjectPrototypeWrongType); // 3. Return ? target.[[SetPrototypeOf]](proto). return Value(TRY(target.as_object().internal_set_prototype_of(proto.is_null() ? nullptr : &proto.as_object()))); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp index d7295a3d9a..ebc4e529b1 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp @@ -113,11 +113,11 @@ ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(StringView pattern, return builder.build(); } -ThrowCompletionOr<String> parse_regex_pattern(StringView pattern, VM& vm, GlobalObject& global_object, bool unicode, bool unicode_sets) +ThrowCompletionOr<String> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets) { auto result = parse_regex_pattern(pattern, unicode, unicode_sets); if (result.is_error()) - return vm.throw_completion<JS::SyntaxError>(global_object, result.release_error().error); + return vm.throw_completion<JS::SyntaxError>(result.release_error().error); return result.release_value(); } @@ -175,16 +175,16 @@ ThrowCompletionOr<RegExpObject*> RegExpObject::regexp_initialize(GlobalObject& g original_pattern = TRY(pattern.to_string(global_object)); bool unicode = f.find('u').has_value(); bool unicode_sets = f.find('v').has_value(); - parsed_pattern = TRY(parse_regex_pattern(original_pattern, vm, global_object, unicode, unicode_sets)); + parsed_pattern = TRY(parse_regex_pattern(vm, original_pattern, unicode, unicode_sets)); } auto parsed_flags_or_error = regex_flags_from_string(f); if (parsed_flags_or_error.is_error()) - return vm.throw_completion<SyntaxError>(global_object, parsed_flags_or_error.release_error()); + return vm.throw_completion<SyntaxError>(parsed_flags_or_error.release_error()); Regex<ECMA262> regex(move(parsed_pattern), parsed_flags_or_error.release_value()); if (regex.parser_result.error != regex::Error::NoError) - return vm.throw_completion<SyntaxError>(global_object, ErrorType::RegExpCompileError, regex.error_string()); + return vm.throw_completion<SyntaxError>(ErrorType::RegExpCompileError, regex.error_string()); m_pattern = move(original_pattern); m_flags = move(f); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.h b/Userland/Libraries/LibJS/Runtime/RegExpObject.h index ddce90133a..799535c6c7 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpObject.h +++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.h @@ -21,7 +21,7 @@ struct ParseRegexPatternError { String error; }; ErrorOr<String, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets); -ThrowCompletionOr<String> parse_regex_pattern(StringView pattern, VM& vm, GlobalObject& global_object, bool unicode, bool unicode_sets); +ThrowCompletionOr<String> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets); class RegExpObject : public Object { JS_OBJECT(RegExpObject, Object); diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp index c23f6202dc..cb0c871e67 100644 --- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp @@ -372,7 +372,7 @@ ThrowCompletionOr<Value> regexp_exec(GlobalObject& global_object, Object& regexp // b. If Type(result) is neither Object nor Null, throw a TypeError exception. if (!result.is_object() && !result.is_null()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOrNull, result.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOrNull, result.to_string_without_side_effects()); // c. Return result. return result; @@ -380,7 +380,7 @@ ThrowCompletionOr<Value> regexp_exec(GlobalObject& global_object, Object& regexp // 3. Perform ? RequireInternalSlot(R, [[RegExpMatcher]]). if (!is<RegExpObject>(regexp_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "RegExp"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "RegExp"); // 4. Return ? RegExpBuiltinExec(R, S). return regexp_builtin_exec(global_object, static_cast<RegExpObject&>(regexp_object), move(string)); @@ -415,24 +415,24 @@ size_t advance_string_index(Utf16View const& string, size_t index, bool unicode) // 22.2.5.15 get RegExp.prototype.sticky, https://tc39.es/ecma262/#sec-get-regexp.prototype.sticky // 22.2.5.18 get RegExp.prototype.unicode, https://tc39.es/ecma262/#sec-get-regexp.prototype.unicode // 22.2.5.18 get RegExp.prototype.unicodeSets, https://arai-a.github.io/ecma262-compare/?pr=2418&id=sec-get-regexp.prototype.unicodeSets -#define __JS_ENUMERATE(flagName, flag_name, flag_char) \ - JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flag_name) \ - { \ - /* 1. If Type(R) is not Object, throw a TypeError exception. */ \ - auto* regexp_object = TRY(this_object(global_object)); \ - /* 2. If R does not have an [[OriginalFlags]] internal slot, then */ \ - if (!is<RegExpObject>(regexp_object)) { \ - /* a. If SameValue(R, %RegExp.prototype%) is true, return undefined. */ \ - if (same_value(regexp_object, global_object.regexp_prototype())) \ - return js_undefined(); \ - /* b. Otherwise, throw a TypeError exception. */ \ - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "RegExp"); \ - } \ - /* 3. Let flags be R.[[OriginalFlags]]. */ \ - auto const& flags = static_cast<RegExpObject*>(regexp_object)->flags(); \ - /* 4. If flags contains codeUnit, return true. */ \ - /* 5. Return false. */ \ - return Value(flags.contains(#flag_char##sv)); \ +#define __JS_ENUMERATE(flagName, flag_name, flag_char) \ + JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flag_name) \ + { \ + /* 1. If Type(R) is not Object, throw a TypeError exception. */ \ + auto* regexp_object = TRY(this_object(global_object)); \ + /* 2. If R does not have an [[OriginalFlags]] internal slot, then */ \ + if (!is<RegExpObject>(regexp_object)) { \ + /* a. If SameValue(R, %RegExp.prototype%) is true, return undefined. */ \ + if (same_value(regexp_object, global_object.regexp_prototype())) \ + return js_undefined(); \ + /* b. Otherwise, throw a TypeError exception. */ \ + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "RegExp"); \ + } \ + /* 3. Let flags be R.[[OriginalFlags]]. */ \ + auto const& flags = static_cast<RegExpObject*>(regexp_object)->flags(); \ + /* 4. If flags contains codeUnit, return true. */ \ + /* 5. Return false. */ \ + return Value(flags.contains(#flag_char##sv)); \ } JS_ENUMERATE_REGEXP_FLAGS #undef __JS_ENUMERATE @@ -856,7 +856,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::source) return js_string(vm, "(?:)"); // b. Otherwise, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "RegExp"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "RegExp"); } // 4. Assert: R has an [[OriginalFlags]] internal slot. @@ -1073,7 +1073,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::compile) if (pattern.is_object() && is<RegExpObject>(pattern.as_object())) { // a. If flags is not undefined, throw a TypeError exception. if (!flags.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotUndefined, flags.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotUndefined, flags.to_string_without_side_effects()); auto& regexp_pattern = static_cast<RegExpObject&>(pattern.as_object()); diff --git a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp index eeaf366e9a..d2cdf4b0a0 100644 --- a/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetConstructor.cpp @@ -35,7 +35,7 @@ void SetConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> SetConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.Set); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.Set); } // 24.2.1.1 Set ( [ iterable ] ), https://tc39.es/ecma262/#sec-set-iterable @@ -51,7 +51,7 @@ ThrowCompletionOr<Object*> SetConstructor::construct(FunctionObject& new_target) auto adder = TRY(set->get(vm.names.add)); if (!adder.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, "'add' property of Set"); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, "'add' property of Set"); (void)TRY(get_iterator_values(global_object, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { TRY(JS::call(global_object, adder.as_function(), set, iterator_value)); diff --git a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp index 2035550653..cf3eba25ab 100644 --- a/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SetPrototype.cpp @@ -82,7 +82,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each) { auto* set = TRY(typed_this_object(global_object)); if (!vm.argument(0).is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects()); auto this_value = vm.this_value(global_object); for (auto& entry : *set) TRY(call(global_object, vm.argument(0).as_function(), vm.argument(1), entry.key, entry.key, this_value)); diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp index 885f904d0b..22b9c7a09a 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealm.cpp @@ -111,7 +111,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(GlobalObject& global_object, // b. If script is a List of errors, throw a SyntaxError exception. if (parser.has_errors()) { auto& error = parser.errors()[0]; - return vm.throw_completion<SyntaxError>(global_object, error.to_string()); + return vm.throw_completion<SyntaxError>(error.to_string()); } // c. If script Contains ScriptBody is false, return undefined. @@ -197,7 +197,7 @@ ThrowCompletionOr<Value> perform_shadow_realm_eval(GlobalObject& global_object, // 21. If result.[[Type]] is not normal, throw a TypeError exception. if (result.type() != Completion::Type::Normal) - return vm.throw_completion<TypeError>(global_object, ErrorType::ShadowRealmEvaluateAbruptCompletion); + return vm.throw_completion<TypeError>(ErrorType::ShadowRealmEvaluateAbruptCompletion); // 22. Return ? GetWrappedValue(callerRealm, result.[[Value]]). return get_wrapped_value(global_object, caller_realm, *result.value()); @@ -251,7 +251,7 @@ ThrowCompletionOr<Value> shadow_realm_import_value(GlobalObject& global_object, // 6. If hasOwn is false, throw a TypeError exception. if (!has_own) - return vm.template throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, string); + return vm.template throw_completion<TypeError>(ErrorType::MissingRequiredProperty, string); // 7. Let value be ? Get(exports, string). auto value = TRY(exports.get(string)); @@ -273,8 +273,8 @@ ThrowCompletionOr<Value> shadow_realm_import_value(GlobalObject& global_object, // NOTE: Even though the spec tells us to use %ThrowTypeError%, it's not observable if we actually do. // Throw a nicer TypeError forwarding the import error message instead (we know the argument is an Error object). - auto* throw_type_error = NativeFunction::create(realm, {}, [](auto& vm, auto& global_object) -> ThrowCompletionOr<Value> { - return vm.template throw_completion<TypeError>(global_object, vm.argument(0).as_object().get_without_side_effects(vm.names.message).as_string().string()); + auto* throw_type_error = NativeFunction::create(realm, {}, [](auto& vm, auto&) -> ThrowCompletionOr<Value> { + return vm.template throw_completion<TypeError>(vm.argument(0).as_object().get_without_side_effects(vm.names.message).as_string().string()); }); // 13. Return PerformPromiseThen(innerCapability.[[Promise]], onFulfilled, callerRealm.[[Intrinsics]].[[%ThrowTypeError%]], promiseCapability). @@ -291,7 +291,7 @@ ThrowCompletionOr<Value> get_wrapped_value(GlobalObject& global_object, Realm& c if (value.is_object()) { // a. If IsCallable(value) is false, throw a TypeError exception. if (!value.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ShadowRealmWrappedValueNonFunctionObject, value); + return vm.throw_completion<TypeError>(ErrorType::ShadowRealmWrappedValueNonFunctionObject, value); // b. Return ? WrappedFunctionCreate(callerRealm, value). return TRY(WrappedFunction::create(realm, caller_realm, value.as_function())); diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp index 8abf0e5f95..533d1b83be 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -33,7 +33,7 @@ ThrowCompletionOr<Value> ShadowRealmConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.ShadowRealm); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ShadowRealm); } // 3.2.1 ShadowRealm ( ), https://tc39.es/proposal-shadowrealm/#sec-shadowrealm diff --git a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp index fc527521fe..4b80913a91 100644 --- a/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ShadowRealmPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate) // 3. If Type(sourceText) is not String, throw a TypeError exception. if (!source_text.is_string()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAString, source_text); + return vm.throw_completion<TypeError>(ErrorType::NotAString, source_text); // 4. Let callerRealm be the current Realm Record. auto* caller_realm = vm.current_realm(); @@ -67,7 +67,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value) // 4. If Type(exportName) is not String, throw a TypeError exception. if (!export_name.is_string()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAString, export_name.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAString, export_name.to_string_without_side_effects()); // 5. Let callerRealm be the current Realm Record. auto* caller_realm = vm.current_realm(); diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 167feab1b6..420ac933b5 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -118,10 +118,10 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point) for (size_t i = 0; i < vm.argument_count(); ++i) { auto next_code_point = TRY(vm.argument(i).to_number(global_object)); if (!next_code_point.is_integral_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidCodePoint, next_code_point.to_string_without_side_effects()); + return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, next_code_point.to_string_without_side_effects()); auto code_point = TRY(next_code_point.to_i32(global_object)); if (code_point < 0 || code_point > 0x10FFFF) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidCodePoint, next_code_point.to_string_without_side_effects()); + return vm.throw_completion<RangeError>(ErrorType::InvalidCodePoint, next_code_point.to_string_without_side_effects()); AK::code_point_to_utf16(string, static_cast<u32>(code_point)); } diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index a48a5c2217..d48bfda8be 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -172,7 +172,7 @@ static ThrowCompletionOr<PrimitiveString*> this_string_value(GlobalObject& globa if (value.is_object() && is<StringObject>(value.as_object())) return &static_cast<StringObject&>(value.as_object()).primitive_string(); auto& vm = global_object.vm(); - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "String"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "String"); } // 22.1.3.2 String.prototype.charAt ( pos ), https://tc39.es/ecma262/#sec-string.prototype.charat @@ -217,10 +217,10 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::repeat) auto n = TRY(vm.argument(0).to_integer_or_infinity(global_object)); if (n < 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::StringRepeatCountMustBe, "positive"); + return vm.throw_completion<RangeError>(ErrorType::StringRepeatCountMustBe, "positive"); if (Value(n).is_positive_infinity()) - return vm.throw_completion<RangeError>(global_object, ErrorType::StringRepeatCountMustBe, "finite"); + return vm.throw_completion<RangeError>(ErrorType::StringRepeatCountMustBe, "finite"); if (n == 0) return js_string(vm, String::empty()); @@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::starts_with) bool search_is_regexp = TRY(search_string_value.is_regexp(global_object)); if (search_is_regexp) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "searchString", "string, but a regular expression"); + return vm.throw_completion<TypeError>(ErrorType::IsNotA, "searchString", "string, but a regular expression"); auto search_string = TRY(search_string_value.to_utf16_string(global_object)); auto string_length = string.length_in_code_units(); @@ -276,7 +276,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::ends_with) bool search_is_regexp = TRY(search_string_value.is_regexp(global_object)); if (search_is_regexp) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "searchString", "string, but a regular expression"); + return vm.throw_completion<TypeError>(ErrorType::IsNotA, "searchString", "string, but a regular expression"); auto search_string = TRY(search_string_value.to_utf16_string(global_object)); auto string_length = string.length_in_code_units(); @@ -602,7 +602,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::includes) bool search_is_regexp = TRY(search_string_value.is_regexp(global_object)); if (search_is_regexp) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "searchString", "string, but a regular expression"); + return vm.throw_completion<TypeError>(ErrorType::IsNotA, "searchString", "string, but a regular expression"); auto search_string = TRY(search_string_value.to_utf16_string(global_object)); @@ -808,7 +808,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all) auto flags_object = TRY(require_object_coercible(global_object, flags)); auto flags_string = TRY(flags_object.to_string(global_object)); if (!flags_string.contains('g')) - return vm.throw_completion<TypeError>(global_object, ErrorType::StringNonGlobalRegExp); + return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp); } if (auto* matcher = TRY(regexp.get_method(global_object, *vm.well_known_symbol_match_all()))) return TRY(call(global_object, *matcher, regexp, this_object)); @@ -836,7 +836,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize) // 5. If f is not one of "NFC", "NFD", "NFKC", or "NFKD", throw a RangeError exception. if (!form.is_one_of("NFC"sv, "NFD"sv, "NFKC"sv, "NFKD"sv)) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidNormalizationForm, form); + return vm.throw_completion<RangeError>(ErrorType::InvalidNormalizationForm, form); // FIXME: 6. Let ns be the String value that is the result of normalizing S into the normalization form named by f as specified in https://unicode.org/reports/tr15/. auto ns = string; @@ -902,7 +902,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::replace_all) auto flags_object = TRY(require_object_coercible(global_object, flags)); auto flags_string = TRY(flags_object.to_string(global_object)); if (!flags_string.contains('g')) - return vm.throw_completion<TypeError>(global_object, ErrorType::StringNonGlobalRegExp); + return vm.throw_completion<TypeError>(ErrorType::StringNonGlobalRegExp); } auto* replacer = TRY(search_value.get_method(global_object, *vm.well_known_symbol_replace())); diff --git a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp index e8a60695ab..e6583d0f65 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolConstructor.cpp @@ -46,7 +46,7 @@ ThrowCompletionOr<Value> SymbolConstructor::call() // 20.4.1.1 Symbol ( [ description ] ), https://tc39.es/ecma262/#sec-symbol-description ThrowCompletionOr<Object*> SymbolConstructor::construct(FunctionObject&) { - return vm().throw_completion<TypeError>(global_object(), ErrorType::NotAConstructor, "Symbol"); + return vm().throw_completion<TypeError>(ErrorType::NotAConstructor, "Symbol"); } // 20.4.2.2 Symbol.for ( key ), https://tc39.es/ecma262/#sec-symbol.for @@ -61,7 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(SymbolConstructor::key_for) { auto argument = vm.argument(0); if (!argument.is_symbol()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotASymbol, argument.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotASymbol, argument.to_string_without_side_effects()); auto& symbol = argument.as_symbol(); if (symbol.is_global()) diff --git a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp index 174889c60c..38791041db 100644 --- a/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/SymbolPrototype.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> - * Copyright (c) 2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -45,7 +45,7 @@ static ThrowCompletionOr<Symbol*> this_symbol_value(GlobalObject& global_object, if (value.is_object() && is<SymbolObject>(value.as_object())) return &static_cast<SymbolObject&>(value.as_object()).primitive_symbol(); auto& vm = global_object.vm(); - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Symbol"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Symbol"); } // 20.4.3.2 get Symbol.prototype.description, https://tc39.es/ecma262/#sec-symbol.prototype.description diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index f5adef89f0..d579d96b5e 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -65,7 +65,7 @@ ThrowCompletionOr<MarkedVector<Value>> iterable_to_list_of_type(GlobalObject& gl // ii. If Type(nextValue) is not an element of elementTypes, then if (auto type = to_option_type(next_value); !type.has_value() || !element_types.contains_slow(*type)) { // 1. Let completion be ThrowCompletion(a newly created TypeError object). - auto completion = vm.throw_completion<TypeError>(global_object, ErrorType::IterableToListOfTypeInvalidValue, next_value.to_string_without_side_effects()); + auto completion = vm.throw_completion<TypeError>(ErrorType::IterableToListOfTypeInvalidValue, next_value.to_string_without_side_effects()); // 2. Return ? IteratorClose(iteratorRecord, completion). return iterator_close(global_object, iterator_record, move(completion)); } @@ -97,7 +97,7 @@ ThrowCompletionOr<Object*> get_options_object(GlobalObject& global_object, Value } // 3. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, "Options"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, "Options"); } // 13.3 GetOption ( options, property, type, values, fallback ), https://tc39.es/proposal-temporal/#sec-getoption @@ -114,7 +114,7 @@ ThrowCompletionOr<Value> get_option(GlobalObject& global_object, Object const& o if (value.is_undefined()) { // a. If default is required, throw a RangeError exception. if (default_.has<GetOptionRequired>()) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, "undefined"sv, property.as_string()); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, "undefined"sv, property.as_string()); // b. Return default. return default_.visit( @@ -137,7 +137,7 @@ ThrowCompletionOr<Value> get_option(GlobalObject& global_object, Object const& o // b. If value is NaN, throw a RangeError exception. if (value.is_nan()) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, vm.names.NaN.as_string(), property.as_string()); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, vm.names.NaN.as_string(), property.as_string()); } // 7. Else, else { @@ -153,7 +153,7 @@ ThrowCompletionOr<Value> get_option(GlobalObject& global_object, Object const& o // NOTE: Every location in the spec that invokes GetOption with type=boolean also has values=undefined. VERIFY(value.is_string()); if (!values.contains_slow(value.as_string().string())) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, value.as_string().string(), property.as_string()); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, value.as_string().string(), property.as_string()); } // 9. Return value. @@ -305,7 +305,7 @@ ThrowCompletionOr<u64> to_temporal_rounding_increment(GlobalObject& global_objec // 6. If increment < 1๐ฝ or increment > maximum, throw a RangeError exception. if (increment < 1 || increment > maximum) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, increment, "roundingIncrement"); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, increment, "roundingIncrement"); // 7. Set increment to floor(โ(increment)). auto floored_increment = static_cast<u64>(increment); @@ -313,7 +313,7 @@ ThrowCompletionOr<u64> to_temporal_rounding_increment(GlobalObject& global_objec // 8. If dividend is not undefined and dividend modulo increment is not zero, then if (dividend.has_value() && static_cast<u64>(*dividend) % floored_increment != 0) // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, increment, "roundingIncrement"); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, increment, "roundingIncrement"); // 9. Return increment. return floored_increment; @@ -350,7 +350,7 @@ ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(GlobalObje // 2. If smallestUnit is "hour", throw a RangeError exception. if (smallest_unit == "hour"sv) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, *smallest_unit, "smallestUnit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, *smallest_unit, "smallestUnit"sv); // 3. If smallestUnit is "minute", then if (smallest_unit == "minute"sv) { @@ -394,7 +394,7 @@ ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(GlobalObje if (!fractional_digits_value.is_undefined()) { // i. If ? ToString(fractionalDigitsVal) is not "auto", throw a RangeError exception. if (TRY(fractional_digits_value.to_string(global_object)) != "auto"sv) - return vm.template throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); + return vm.template throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); } // b. Return the Record { [[Precision]]: "auto", [[Unit]]: "nanosecond", [[Increment]]: 1 }. @@ -403,14 +403,14 @@ ThrowCompletionOr<SecondsStringPrecision> to_seconds_string_precision(GlobalObje // 11. If fractionalDigitsVal is NaN, +โ๐ฝ, or -โ๐ฝ, throw a RangeError exception. if (fractional_digits_value.is_nan() || fractional_digits_value.is_infinity()) - return vm.template throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); + return vm.template throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); // 12. Let fractionalDigitCount be RoundTowardsZero(โ(fractionalDigitsVal)). auto fractional_digit_count_unchecked = trunc(fractional_digits_value.as_double()); // 13. If fractionalDigitCount < 0 or fractionalDigitCount > 9, throw a RangeError exception. if (fractional_digit_count_unchecked < 0 || fractional_digit_count_unchecked > 9) - return vm.template throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); + return vm.template throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, fractional_digits_value, "fractionalSecondDigits"sv); auto fractional_digit_count = static_cast<u8>(fractional_digit_count_unchecked); @@ -531,7 +531,7 @@ ThrowCompletionOr<Optional<String>> get_temporal_unit(GlobalObject& global_objec // 10. If value is undefined and default is required, throw a RangeError exception. if (option_value.is_undefined() && default_.has<TemporalUnitRequired>()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IsUndefined, String::formatted("{} option value", key.as_string())); + return vm.throw_completion<RangeError>(ErrorType::IsUndefined, String::formatted("{} option value", key.as_string())); Optional<String> value = option_value.is_undefined() ? Optional<String> {} @@ -657,7 +657,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(GlobalObject& global_object if (!is_valid_time_zone_numeric_utc_offset_syntax(*time_zone_name)) { // 1. If IsValidTimeZoneName(timeZoneName) is false, throw a RangeError exception. if (!is_valid_time_zone_name(*time_zone_name)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneName, *time_zone_name); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneName, *time_zone_name); // 2. Set timeZoneName to ! CanonicalizeTimeZoneName(timeZoneName). time_zone_name = canonicalize_time_zone_name(*time_zone_name); @@ -809,7 +809,7 @@ ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(GlobalObject& g // 2. If object has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then if (is<PlainDate>(object) || is<PlainDateTime>(object) || is<PlainMonthDay>(object) || is<PlainTime>(object) || is<PlainYearMonth>(object) || is<ZonedDateTime>(object)) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalObjectMustNotHave, "calendar or timeZone"); + return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustNotHave, "calendar or timeZone"); } // 3. Let calendarProperty be ? Get(object, "calendar"). @@ -818,7 +818,7 @@ ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(GlobalObject& g // 4. If calendarProperty is not undefined, then if (!calendar_property.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalObjectMustNotHave, "calendar"); + return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustNotHave, "calendar"); } // 5. Let timeZoneProperty be ? Get(object, "timeZone"). @@ -827,7 +827,7 @@ ThrowCompletionOr<void> reject_object_with_calendar_or_time_zone(GlobalObject& g // 6. If timeZoneProperty is not undefined, then if (!time_zone_property.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalObjectMustNotHave, "timeZone"); + return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustNotHave, "timeZone"); } return {}; @@ -1315,11 +1315,11 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(GlobalObject& global_object, // 20. If IsValidISODate(yearMV, monthMV, dayMV) is false, throw a RangeError exception. if (!is_valid_iso_date(year_mv, month_mv, day_mv)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidISODate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidISODate); // 21. If IsValidTime(hourMV, minuteMV, secondMV, millisecondMV, microsecondMV, nanosecondMV) is false, throw a RangeError exception. if (!is_valid_time(hour_mv, minute_mv, second_mv, millisecond_mv, microsecond_mv, nanosecond_mv)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTime); Optional<String> calendar_val; @@ -1347,7 +1347,7 @@ ThrowCompletionOr<TemporalInstant> parse_temporal_instant_string(GlobalObject& g // 1. If ParseText(StringToCodePoints(isoString), TemporalInstantString) is a List of errors, throw a RangeError exception. auto parse_result = parse_iso8601(Production::TemporalInstantString, iso_string); if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidInstantString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidInstantString, iso_string); // 2. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1379,7 +1379,7 @@ ThrowCompletionOr<TemporalZonedDateTime> parse_temporal_zoned_date_time_string(G // 1. If ParseText(StringToCodePoints(isoString), TemporalZonedDateTimeString) is a List of errors, throw a RangeError exception. auto parse_result = parse_iso8601(Production::TemporalZonedDateTimeString, iso_string); if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidZonedDateTimeString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidZonedDateTimeString, iso_string); // 2. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1403,7 +1403,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject& global_ob // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarString, iso_string); // 3. Let id be the source text matched by the CalendarName Parse Node contained within parseResult, or an empty sequence of code points if not present. auto id = parse_result->calendar_name; @@ -1438,11 +1438,11 @@ ThrowCompletionOr<ISODateTime> parse_temporal_date_time_string(GlobalObject& glo // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateTimeString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDateTimeString, iso_string); // 3. If parseResult contains a UTCDesignator Parse Node, throw a RangeError exception. if (parse_result->utc_designator.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateTimeStringUTCDesignator, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDateTimeStringUTCDesignator, iso_string); // 4. Return ? ParseISODateTime(isoString). return parse_iso_date_time(global_object, *parse_result); @@ -1458,7 +1458,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(GlobalObject& g // 2. If duration is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationString, iso_string); // 3. Let each of sign, years, months, weeks, days, hours, fHours, minutes, fMinutes, seconds, and fSeconds be the source text matched by the respective Sign, DurationYears, DurationMonths, DurationWeeks, DurationDays, DurationWholeHours, DurationHoursFraction, DurationWholeMinutes, DurationMinutesFraction, DurationWholeSeconds, and DurationSecondsFraction Parse Node contained within duration, or an empty sequence of code points if not present. auto sign_part = parse_result->sign; @@ -1496,7 +1496,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(GlobalObject& g if (f_hours_part.has_value()) { // a. If any of minutes, fMinutes, seconds, fSeconds is not empty, throw a RangeError exception. if (minutes_part.has_value() || f_minutes_part.has_value() || seconds_part.has_value() || f_seconds_part.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationStringFractionNotLast, iso_string, "hours"sv, "minutes or seconds"sv); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationStringFractionNotLast, iso_string, "hours"sv, "minutes or seconds"sv); // b. Let fHoursDigits be the substring of CodePointsToString(fHours) from 1. auto f_hours_digits = f_hours_part->substring_view(1); @@ -1519,7 +1519,7 @@ ThrowCompletionOr<DurationRecord> parse_temporal_duration_string(GlobalObject& g if (f_minutes_part.has_value()) { // a. If any of seconds, fSeconds is not empty, throw a RangeError exception. if (seconds_part.has_value() || f_seconds_part.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationStringFractionNotLast, iso_string, "minutes"sv, "seconds"sv); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationStringFractionNotLast, iso_string, "minutes"sv, "seconds"sv); // b. Let fMinutesDigits be the substring of CodePointsToString(fMinutes) from 1. auto f_minutes_digits = f_minutes_part->substring_view(1); @@ -1598,11 +1598,11 @@ ThrowCompletionOr<TemporalMonthDay> parse_temporal_month_day_string(GlobalObject // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthDayString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthDayString, iso_string); // 3. If parseResult contains a UTCDesignator Parse Node, throw a RangeError exception. if (parse_result->utc_designator.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthDayStringUTCDesignator, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthDayStringUTCDesignator, iso_string); // 4. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1628,7 +1628,7 @@ ThrowCompletionOr<TemporalZonedDateTime> parse_temporal_relative_to_string(Globa // 1. If ParseText(StringToCodePoints(isoString), TemporalDateTimeString) is a List of errors, throw a RangeError exception. auto parse_result = parse_iso8601(Production::TemporalDateTimeString, iso_string); if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateTimeString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDateTimeString, iso_string); // 2. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1675,11 +1675,11 @@ ThrowCompletionOr<TemporalTime> parse_temporal_time_string(GlobalObject& global_ // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeString, iso_string); // 3. If parseResult contains a UTCDesignator Parse Node, throw a RangeError exception. if (parse_result->utc_designator.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeStringUTCDesignator, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeStringUTCDesignator, iso_string); // 4. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1698,7 +1698,7 @@ ThrowCompletionOr<TemporalTimeZone> parse_temporal_time_zone_string(GlobalObject // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneString, iso_string); // 3. Let each of z, offsetString, and name be the source text matched by the respective UTCDesignator, TimeZoneNumericUTCOffset, and TimeZoneIdentifier Parse Nodes contained within parseResult, or an empty sequence of code points if not present. auto z = parse_result->utc_designator; @@ -1737,11 +1737,11 @@ ThrowCompletionOr<TemporalYearMonth> parse_temporal_year_month_string(GlobalObje // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidYearMonthString, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidYearMonthString, iso_string); // 3. If parseResult contains a UTCDesignator Parse Node, throw a RangeError exception. if (parse_result->utc_designator.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidYearMonthStringUTCDesignator, iso_string); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidYearMonthStringUTCDesignator, iso_string); // 4. Let result be ? ParseISODateTime(isoString). auto result = TRY(parse_iso_date_time(global_object, *parse_result)); @@ -1761,7 +1761,7 @@ ThrowCompletionOr<double> to_positive_integer(GlobalObject& global_object, Value // 2. If integer โค 0, then if (integer <= 0) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalPropertyMustBePositiveInteger); + return vm.throw_completion<RangeError>(ErrorType::TemporalPropertyMustBePositiveInteger); } // 3. Return integer. @@ -1820,7 +1820,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(GlobalObject& global_object, // i. If requiredFields contains property, then if (required_fields.get<Vector<StringView>>().contains_slow(property)) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, property); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, property); } // ii. If property is in the Property column of Table 13, then // NOTE: The other properties in the table are automatically handled as their default value is undefined @@ -1837,7 +1837,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(GlobalObject& global_object, // 4. If requiredFields is partial and any is false, then if (required_fields.has<PrepareTemporalFieldsPartial>() && !any) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalObjectMustHaveOneOf, String::join(", "sv, field_names)); + return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, String::join(", "sv, field_names)); } // 5. Return result. @@ -1857,7 +1857,7 @@ ThrowCompletionOr<DifferenceSettings> get_difference_settings(GlobalObject& glob // 3. If disallowedUnits contains smallestUnit, throw a RangeError exception. if (disallowed_units.contains_slow(*smallest_unit)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, *smallest_unit, "smallestUnit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, *smallest_unit, "smallestUnit"sv); // 4. Let defaultLargestUnit be ! LargerOfTwoTemporalUnits(smallestLargestDefaultUnit, smallestUnit). auto default_largest_unit = larger_of_two_temporal_units(smallest_largest_default_unit, *smallest_unit); @@ -1867,7 +1867,7 @@ ThrowCompletionOr<DifferenceSettings> get_difference_settings(GlobalObject& glob // 6. If disallowedUnits contains largestUnit, throw a RangeError exception. if (disallowed_units.contains_slow(*largest_unit)) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, *largest_unit, "largestUnit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, *largest_unit, "largestUnit"sv); // 7. If largestUnit is "auto", set largestUnit to defaultLargestUnit. if (largest_unit == "auto"sv) @@ -1875,7 +1875,7 @@ ThrowCompletionOr<DifferenceSettings> get_difference_settings(GlobalObject& glob // 8. If LargerOfTwoTemporalUnits(largestUnit, smallestUnit) is not largestUnit, throw a RangeError exception. if (larger_of_two_temporal_units(*largest_unit, *smallest_unit) != largest_unit) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidUnitRange, *smallest_unit, *largest_unit); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidUnitRange, *smallest_unit, *largest_unit); // 9. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc"). auto rounding_mode = TRY(to_temporal_rounding_mode(global_object, *options, "trunc"sv)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h index 4f91cc0a39..4dd247ba54 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.h @@ -199,7 +199,7 @@ ThrowCompletionOr<double> to_integer_throw_on_infinity(GlobalObject& global_obje // 2. If integer is -โ or +โ , then if (Value(integer).is_infinity()) { // a. Throw a RangeError exception. - return vm.template throw_completion<RangeError>(global_object, error_type, args...); + return vm.template throw_completion<RangeError>(error_type, args...); } // 3. Return integer. @@ -221,7 +221,7 @@ ThrowCompletionOr<double> to_integer_without_rounding(GlobalObject& global_objec // 3. If IsIntegralNumber(number) is false, throw a RangeError exception. if (!number.is_integral_number()) - return vm.template throw_completion<RangeError>(global_object, error_type, args...); + return vm.template throw_completion<RangeError>(error_type, args...); // 4. Return โ(number). return number.as_double(); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index aaa227ac49..e1fc4731c1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -85,7 +85,7 @@ ThrowCompletionOr<Calendar*> get_builtin_calendar(GlobalObject& global_object, S // 1. If IsBuiltinCalendar(id) is false, throw a RangeError exception. if (!is_builtin_calendar(identifier)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, identifier); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, identifier); // 2. Return ! CreateTemporalCalendar(id). return MUST(create_temporal_calendar(global_object, identifier)); @@ -147,7 +147,7 @@ ThrowCompletionOr<Object*> calendar_merge_fields(GlobalObject& global_object, Ob // 4. If Type(result) is not Object, throw a TypeError exception. if (!result.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, result.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, result.to_string_without_side_effects()); // 5. Return result. return &result.as_object(); @@ -173,7 +173,7 @@ ThrowCompletionOr<PlainDate*> calendar_date_add(GlobalObject& global_object, Obj // 6. Perform ? RequireInternalSlot(addedDate, [[InitializedTemporalDate]]). auto* added_date_object = TRY(added_date.to_object(global_object)); if (!is<PlainDate>(added_date_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainDate"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.PlainDate"); // 7. Return addedDate. return static_cast<PlainDate*>(added_date_object); @@ -196,7 +196,7 @@ ThrowCompletionOr<Duration*> calendar_date_until(GlobalObject& global_object, Ob // 4. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). auto* duration_object = TRY(duration.to_object(global_object)); if (!is<Duration>(duration_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.Duration"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.Duration"); // 5. Return duration. return static_cast<Duration*>(duration_object); @@ -213,7 +213,7 @@ ThrowCompletionOr<double> calendar_year(GlobalObject& global_object, Object& cal // 3. If result is undefined, throw a RangeError exception. if (result.is_undefined()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.year.as_string(), vm.names.undefined.as_string()); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.year.as_string(), vm.names.undefined.as_string()); // 4. Return ? ToIntegerThrowOnInfinity(result). return TRY(to_integer_throw_on_infinity(global_object, result, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.year.as_string(), vm.names.Infinity.as_string())); @@ -230,7 +230,7 @@ ThrowCompletionOr<double> calendar_month(GlobalObject& global_object, Object& ca // NOTE: Explicitly handled for a better error message similar to the other calendar property AOs if (result.is_undefined()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.month.as_string(), vm.names.undefined.as_string()); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.month.as_string(), vm.names.undefined.as_string()); // 3. Return ? ToPositiveInteger(result). return TRY(to_positive_integer(global_object, result)); @@ -247,7 +247,7 @@ ThrowCompletionOr<String> calendar_month_code(GlobalObject& global_object, Objec // 3. If result is undefined, throw a RangeError exception. if (result.is_undefined()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.monthCode.as_string(), vm.names.undefined.as_string()); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.monthCode.as_string(), vm.names.undefined.as_string()); // 4. Return ? ToString(result). return result.to_string(global_object); @@ -264,7 +264,7 @@ ThrowCompletionOr<double> calendar_day(GlobalObject& global_object, Object& cale // NOTE: Explicitly handled for a better error message similar to the other calendar property AOs if (result.is_undefined()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.day.as_string(), vm.names.undefined.as_string()); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.day.as_string(), vm.names.undefined.as_string()); // 3. Return ? ToPositiveInteger(result). return TRY(to_positive_integer(global_object, result)); @@ -431,7 +431,7 @@ ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject& global_object, Val // b. If IsBuiltinCalendar(identifier) is false, throw a RangeError exception. if (!is_builtin_calendar(identifier)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, identifier); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, identifier); } // 4. Return ! CreateTemporalCalendar(identifier). @@ -490,7 +490,7 @@ ThrowCompletionOr<PlainDate*> calendar_date_from_fields(GlobalObject& global_obj // 3. Perform ? RequireInternalSlot(date, [[InitializedTemporalDate]]). auto* date_object = TRY(date.to_object(global_object)); if (!is<PlainDate>(date_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainDate"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.PlainDate"); // 4. Return date. return static_cast<PlainDate*>(date_object); @@ -509,7 +509,7 @@ ThrowCompletionOr<PlainYearMonth*> calendar_year_month_from_fields(GlobalObject& // 3. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). auto* year_month_object = TRY(year_month.to_object(global_object)); if (!is<PlainYearMonth>(year_month_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainYearMonth"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.PlainYearMonth"); // 4. Return yearMonth. return static_cast<PlainYearMonth*>(year_month_object); @@ -528,7 +528,7 @@ ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(GlobalObject& g // 3. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). auto* month_day_object = TRY(month_day.to_object(global_object)); if (!is<PlainMonthDay>(month_day_object)) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.PlainMonthDay"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.PlainMonthDay"); // 4. Return monthDay. return static_cast<PlainMonthDay*>(month_day_object); @@ -600,7 +600,7 @@ ThrowCompletionOr<Object*> consolidate_calendars(GlobalObject& global_object, Ob return &one; // 7. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendar); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendar); } // 12.2.29 ISODaysInMonth ( year, month ), https://tc39.es/proposal-temporal/#sec-temporal-isodaysinmonth @@ -683,7 +683,7 @@ ThrowCompletionOr<double> resolve_iso_month(GlobalObject& global_object, Object if (month_code.is_undefined()) { // a. If month is undefined, throw a TypeError exception. if (month.is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.month.as_string()); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, vm.names.month.as_string()); // b. Assert: Type(month) is Number. VERIFY(month.is_number()); @@ -701,7 +701,7 @@ ThrowCompletionOr<double> resolve_iso_month(GlobalObject& global_object, Object // 7. If monthLength is not 3, throw a RangeError exception. if (month_length != 3) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthCode); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthCode); // 8. Let numberPart be the substring of monthCode from 1. auto number_part = month_code_string.substring(1); @@ -711,18 +711,18 @@ ThrowCompletionOr<double> resolve_iso_month(GlobalObject& global_object, Object // 10. If numberPart < 1 or numberPart > 12, throw a RangeError exception. if (number_part_integer < 1 || number_part_integer > 12) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthCode); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthCode); // 11. If month is not undefined and month โ numberPart, then if (!month.is_undefined() && month.as_double() != number_part_integer) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthCode); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthCode); } // 12. If SameValueNonNumeric(monthCode, ! BuildISOMonthCode(numberPart)) is false, then if (month_code_string != build_iso_month_code(number_part_integer)) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidMonthCode); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthCode); } // 13. Return numberPart. @@ -815,7 +815,7 @@ ThrowCompletionOr<ISOMonthDay> iso_month_day_from_fields(GlobalObject& global_ob // 7. If month is not undefined, and monthCode and year are both undefined, then if (!month_value.is_undefined() && month_code.is_undefined() && year.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, "monthCode or year"); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, "monthCode or year"); } // 8. Set month to ? ResolveISOMonth(fields). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp index 9361321e1a..47fd73d3ae 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarConstructor.cpp @@ -38,7 +38,7 @@ ThrowCompletionOr<Value> CalendarConstructor::call() // 1. If NewTarget is undefined, then // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.Calendar"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.Calendar"); } // 12.2.1 Temporal.Calendar ( id ), https://tc39.es/proposal-temporal/#sec-temporal.calendar @@ -53,7 +53,7 @@ ThrowCompletionOr<Object*> CalendarConstructor::construct(FunctionObject& new_ta // 3. If IsBuiltinCalendar(id) is false, then if (!is_builtin_calendar(identifier)) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, identifier); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, identifier); } // 4. Return ? CreateTemporalCalendar(id, NewTarget). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index d4a1878c2b..0690c7c4db 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields) // 4. If Type(fields) is not Object, throw a TypeError exception. auto fields = vm.argument(0); if (!fields.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, fields.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects()); // 5. Set options to ? GetOptionsObject(options). auto const* options = TRY(get_options_object(global_object, vm.argument(1))); @@ -113,7 +113,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields) // 4. If Type(fields) is not Object, throw a TypeError exception. auto fields = vm.argument(0); if (!fields.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, fields.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects()); // 5. Set options to ? GetOptionsObject(options). auto const* options = TRY(get_options_object(global_object, vm.argument(1))); @@ -139,7 +139,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields) // 4. If Type(fields) is not Object, throw a TypeError exception. auto fields = vm.argument(0); if (!fields.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, fields.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, fields.to_string_without_side_effects()); // 5. Set options to ? GetOptionsObject(options). auto const* options = TRY(get_options_object(global_object, vm.argument(1))); @@ -257,7 +257,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month) // 4. If Type(temporalDateLike) is Object and temporalDateLike has an [[InitializedTemporalMonthDay]] internal slot, then if (temporal_date_like.is_object() && is<PlainMonthDay>(temporal_date_like.as_object())) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalAmbiguousMonthOfPlainMonthDay); + return vm.throw_completion<TypeError>(ErrorType::TemporalAmbiguousMonthOfPlainMonthDay); } // 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then @@ -534,7 +534,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields) // ii. If Type(nextValue) is not String, then if (!next_value.is_string()) { // 1. Let completion be ThrowCompletion(a newly created TypeError object). - auto completion = vm.throw_completion<TypeError>(global_object, ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_string_without_side_effects()); + auto completion = vm.throw_completion<TypeError>(ErrorType::TemporalInvalidCalendarFieldValue, next_value.to_string_without_side_effects()); // 2. Return ? IteratorClose(iteratorRecord, completion). return TRY(iterator_close(global_object, iterator_record, move(completion))); @@ -543,7 +543,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields) // iii. If fieldNames contains nextValue, then if (field_names.contains_slow(next_value)) { // 1. Let completion be ThrowCompletion(a newly created RangeError object). - auto completion = vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDuplicateCalendarField, next_value.as_string().string()); + auto completion = vm.throw_completion<RangeError>(ErrorType::TemporalDuplicateCalendarField, next_value.as_string().string()); // 2. Return ? IteratorClose(iteratorRecord, completion). return TRY(iterator_close(global_object, iterator_record, move(completion))); @@ -552,7 +552,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields) // iv. If nextValue is not one of "year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", then if (!next_value.as_string().string().is_one_of("year"sv, "month"sv, "monthCode"sv, "day"sv, "hour"sv, "minute"sv, "second"sv, "millisecond"sv, "microsecond"sv, "nanosecond"sv)) { // 1. Let completion be ThrowCompletion(a newly created RangeError object). - auto completion = vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFieldName, next_value.as_string().string()); + auto completion = vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarFieldName, next_value.as_string().string()); // 2. Return ? IteratorClose(iteratorRecord, completion). return TRY(iterator_close(global_object, iterator_record, move(completion))); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp index 5b39a6fafb..0737bc6fb2 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Duration.cpp @@ -84,7 +84,7 @@ ThrowCompletionOr<DurationRecord> create_duration_record(GlobalObject& global_ob // 1. If ! IsValidDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, throw a RangeError exception. if (!is_valid_duration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDuration); // 2. Return the Record { [[Years]]: โ(๐ฝ(years)), [[Months]]: โ(๐ฝ(months)), [[Weeks]]: โ(๐ฝ(weeks)), [[Days]]: โ(๐ฝ(days)), [[Hours]]: โ(๐ฝ(hours)), [[Minutes]]: โ(๐ฝ(minutes)), [[Seconds]]: โ(๐ฝ(seconds)), [[Milliseconds]]: โ(๐ฝ(milliseconds)), [[Microseconds]]: โ(๐ฝ(microseconds)), [[Nanoseconds]]: โ(๐ฝ(nanoseconds)) }. return DurationRecord { .years = years, .months = months, .weeks = weeks, .days = days, .hours = hours, .minutes = minutes, .seconds = seconds, .milliseconds = milliseconds, .microseconds = microseconds, .nanoseconds = nanoseconds }; @@ -107,7 +107,7 @@ ThrowCompletionOr<DateDurationRecord> create_date_duration_record(GlobalObject& // 1. If ! IsValidDuration(years, months, weeks, days, 0, 0, 0, 0, 0, 0) is false, throw a RangeError exception. if (!is_valid_duration(years, months, weeks, days, 0, 0, 0, 0, 0, 0)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDuration); // 2. Return the Record { [[Years]]: โ(๐ฝ(years)), [[Months]]: โ(๐ฝ(months)), [[Weeks]]: โ(๐ฝ(weeks)), [[Days]]: โ(๐ฝ(days)) }. return DateDurationRecord { .years = years, .months = months, .weeks = weeks, .days = days }; @@ -120,7 +120,7 @@ ThrowCompletionOr<TimeDurationRecord> create_time_duration_record(GlobalObject& // 1. If ! IsValidDuration(0, 0, 0, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, throw a RangeError exception. if (!is_valid_duration(0, 0, 0, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDuration); // 2. Return the Record { [[Days]]: โ(๐ฝ(days)), [[Hours]]: โ(๐ฝ(hours)), [[Minutes]]: โ(๐ฝ(minutes)), [[Seconds]]: โ(๐ฝ(seconds)), [[Milliseconds]]: โ(๐ฝ(milliseconds)), [[Microseconds]]: โ(๐ฝ(microseconds)), [[Nanoseconds]]: โ(๐ฝ(nanoseconds)) }. return TimeDurationRecord { .days = days, .hours = hours, .minutes = minutes, .seconds = seconds, .milliseconds = milliseconds, .microseconds = microseconds, .nanoseconds = nanoseconds }; @@ -192,7 +192,7 @@ ThrowCompletionOr<DurationRecord> to_temporal_duration_record(GlobalObject& glob // 6. If ! IsValidDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]]) is false, then if (!is_valid_duration(result.years, result.months, result.weeks, result.days, result.hours, result.minutes, result.seconds, result.milliseconds, result.microseconds, result.nanoseconds)) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDuration); } // 7. Return result. @@ -293,7 +293,7 @@ ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(Glo // 1. If Type(temporalDurationLike) is not Object, then if (!temporal_duration_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_duration_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_duration_like.to_string_without_side_effects()); } // 2. Let result be a new partial Duration Record with each field set to undefined. @@ -326,7 +326,7 @@ ThrowCompletionOr<PartialDurationRecord> to_temporal_partial_duration_record(Glo // 5. If any is false, then if (!any) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalInvalidDurationLikeObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalInvalidDurationLikeObject); } // 6. Return result. @@ -340,7 +340,7 @@ ThrowCompletionOr<Duration*> create_temporal_duration(GlobalObject& global_objec // 1. If ! IsValidDuration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds) is false, throw a RangeError exception. if (!is_valid_duration(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDuration); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDuration); // 2. If newTarget is not present, set newTarget to %Temporal.Duration%. if (!new_target) @@ -617,7 +617,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(GlobalObject& // a. If calendar is undefined, then if (!calendar) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingStartingPoint, "months"); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingStartingPoint, "months"); } // b. Let dateAdd be ? GetMethod(calendar, "dateAdd"). @@ -658,7 +658,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(GlobalObject& // a. If calendar is undefined, then if (!calendar) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingStartingPoint, "weeks"); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingStartingPoint, "weeks"); } // b. Repeat, while years โ 0, @@ -698,7 +698,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(GlobalObject& // i. If calendar is undefined, then if (!calendar) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingStartingPoint, "calendar units"); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingStartingPoint, "calendar units"); } // ii. Repeat, while years โ 0, @@ -767,7 +767,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(GlobalObject& gl // 2. If relativeTo is undefined, then if (relative_to_value.is_undefined()) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingStartingPoint, "calendar units"); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingStartingPoint, "calendar units"); } // 3. Let sign be ! DurationSign(years, months, weeks, days, 0, 0, 0, 0, 0, 0). @@ -995,7 +995,7 @@ ThrowCompletionOr<DurationRecord> add_duration(GlobalObject& global_object, doub // a. If largestUnit is one of "year", "month", or "week", then if (largest_unit.is_one_of("year"sv, "month"sv, "week"sv)) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingStartingPoint, "year, month or week"); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingStartingPoint, "year, month or week"); } // b. Let result be ? BalanceDuration(d1 + d2, h1 + h2, min1 + min2, s1 + s2, ms1 + ms2, mus1 + mus2, ns1 + ns2, largestUnit). @@ -1124,7 +1124,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(GlobalObject& global_object, d // 2. If unit is "year", "month", or "week", and relativeTo is undefined, then if (unit.is_one_of("year"sv, "month"sv, "week"sv) && !relative_to_object) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, unit, "smallestUnit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, unit, "smallestUnit"sv); } // 3. Let zonedRelativeTo be undefined. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp index 04d3c99fa0..d5008cc76f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> DurationConstructor::call() // 1. If NewTarget is undefined, then // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.Duration"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.Duration"); } // 7.1.1 Temporal.Duration ( [ years [ , months [ , weeks [ , days [ , hours [ , minutes [ , seconds [ , milliseconds [ , microseconds [ , nanoseconds ] ] ] ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index dabc0c9756..da6a4b548d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -331,7 +331,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::round) // 3. If roundTo is undefined, then if (vm.argument(0).is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); } Object* round_to; @@ -396,12 +396,12 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::round) // 15. If smallestUnitPresent is false and largestUnitPresent is false, then if (!smallest_unit_present && !largest_unit_present) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalMissingUnits); + return vm.throw_completion<RangeError>(ErrorType::TemporalMissingUnits); } // 16. If LargerOfTwoTemporalUnits(largestUnit, smallestUnit) is not largestUnit, throw a RangeError exception. if (larger_of_two_temporal_units(*largest_unit, *smallest_unit) != largest_unit) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidUnitRange, *smallest_unit, *largest_unit); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidUnitRange, *smallest_unit, *largest_unit); // 17. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand"). auto rounding_mode = TRY(to_temporal_rounding_mode(global_object, *round_to, "halfExpand"sv)); @@ -454,7 +454,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::total) // 3. If totalOf is undefined, throw a TypeError exception. if (vm.argument(0).is_undefined()) - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); Object* total_of; @@ -578,7 +578,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_string) // 5. If precision.[[Unit]] is "minute", throw a RangeError exception. if (precision.unit == "minute"sv) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, "minute"sv, "smallestUnit"sv); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, "minute"sv, "smallestUnit"sv); // 6. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc"). auto rounding_mode = TRY(to_temporal_rounding_mode(global_object, *options, "trunc"sv)); @@ -617,7 +617,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_locale_string) JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.Duration", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.Duration", "a primitive value"); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp index 35d34efc06..8f423a8cf3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Instant.cpp @@ -127,7 +127,7 @@ ThrowCompletionOr<BigInt*> parse_temporal_instant(GlobalObject& global_object, S // 8. If ! IsValidEpochNanoseconds(result) is false, then if (!is_valid_epoch_nanoseconds(*result_ns)) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); } // 9. Return result. @@ -169,7 +169,7 @@ ThrowCompletionOr<BigInt*> add_instant(GlobalObject& global_object, BigInt const // 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 3. Return result. return result; @@ -314,19 +314,19 @@ ThrowCompletionOr<Instant*> add_duration_to_or_subtract_duration_from_instant(Gl // 3. If duration.[[Days]] is not 0, throw a RangeError exception. if (duration.days != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonZero, "days", duration.days); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationPropertyValueNonZero, "days", duration.days); // 4. If duration.[[Months]] is not 0, throw a RangeError exception. if (duration.months != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonZero, "months", duration.months); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationPropertyValueNonZero, "months", duration.months); // 5. If duration.[[Weeks]] is not 0, throw a RangeError exception. if (duration.weeks != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonZero, "weeks", duration.weeks); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationPropertyValueNonZero, "weeks", duration.weeks); // 6. If duration.[[Years]] is not 0, throw a RangeError exception. if (duration.years != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDurationPropertyValueNonZero, "years", duration.years); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidDurationPropertyValueNonZero, "years", duration.years); // 7. Let ns be ? AddInstant(instant.[[Nanoseconds]], sign ร duration.[[Hours]], sign ร duration.[[Minutes]], sign ร duration.[[Seconds]], sign ร duration.[[Milliseconds]], sign ร duration.[[Microseconds]], sign ร duration.[[Nanoseconds]]). auto* ns = TRY(add_instant(global_object, instant.nanoseconds(), sign * duration.hours, sign * duration.minutes, sign * duration.seconds, sign * duration.milliseconds, sign * duration.microseconds, sign * duration.nanoseconds)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp index ee1c94200c..caef8ae4b3 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantConstructor.cpp @@ -45,7 +45,7 @@ ThrowCompletionOr<Value> InstantConstructor::call() // 1. If NewTarget is undefined, then // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.Instant"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.Instant"); } // 8.1.1 Temporal.Instant ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant @@ -59,7 +59,7 @@ ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_tar // 3. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget). return TRY(create_temporal_instant(global_object, *epoch_nanoseconds, &new_target)); @@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_seconds) // 4. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 5. Return ! CreateTemporalInstant(epochNanoseconds). return MUST(create_temporal_instant(global_object, *epoch_nanoseconds)); @@ -114,7 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_milliseconds) // 4. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 5. Return ! CreateTemporalInstant(epochNanoseconds). return MUST(create_temporal_instant(global_object, *epoch_nanoseconds)); @@ -131,7 +131,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_microseconds) // 3. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 4. Return ! CreateTemporalInstant(epochNanoseconds). return MUST(create_temporal_instant(global_object, *epoch_nanoseconds)); @@ -145,7 +145,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_nanoseconds) // 2. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 3. Return ! CreateTemporalInstant(epochNanoseconds). return MUST(create_temporal_instant(global_object, *epoch_nanoseconds)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 885e49eff2..937025f054 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -184,7 +184,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round) // 3. If roundTo is undefined, then if (vm.argument(0).is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); } Object* round_to; @@ -210,7 +210,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round) // 6. If smallestUnit is undefined, throw a RangeError exception. if (!smallest_unit_value.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::OptionIsNotValidValue, vm.names.undefined.as_string(), "smallestUnit"); + return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, vm.names.undefined.as_string(), "smallestUnit"); // At this point smallest_unit_value can only be a string auto& smallest_unit = *smallest_unit_value; @@ -342,7 +342,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.Instant", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.Instant", "a primitive value"); } // 8.3.17 Temporal.Instant.prototype.toZonedDateTime ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tozoneddatetime @@ -357,7 +357,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) // 3. If Type(item) is not Object, then if (!item.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, item); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, item); } // 4. Let calendarLike be ? Get(item, "calendar"). @@ -366,7 +366,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) // 5. If calendarLike is undefined, then if (calendar_like.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.calendar.as_string()); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, vm.names.calendar.as_string()); } // 6. Let calendar be ? ToTemporalCalendar(calendarLike). @@ -378,7 +378,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) // 8. If temporalTimeZoneLike is undefined, then if (temporal_time_zone_like.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.timeZone.as_string()); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, vm.names.timeZone.as_string()); } // 9. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp index 602f6e03eb..5130e68804 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDate.cpp @@ -59,11 +59,11 @@ ThrowCompletionOr<PlainDate*> create_temporal_date(GlobalObject& global_object, // 5. If IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception. if (!is_valid_iso_date(iso_year, iso_month, iso_day)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // 6. If ISODateTimeWithinLimits(isoYear, isoMonth, isoDay, 12, 0, 0, 0, 0, 0) is false, throw a RangeError exception. if (!iso_date_time_within_limits(global_object, iso_year, iso_month, iso_day, 12, 0, 0, 0, 0, 0)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // 7. If newTarget is not present, set newTarget to %Temporal.PlainDate%. if (!new_target) @@ -322,7 +322,7 @@ ThrowCompletionOr<ISODateRecord> regulate_iso_date(GlobalObject& global_object, // does not change the exposed behavior as the parent's call to CreateTemporalDate will immediately check that this value is a valid // ISO value for years: -273975 - 273975, which is a subset of this check. if (!AK::is_within_range<i32>(year)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // a. Set month to the result of clamping month between 1 and 12. month = clamp(month, 1, 12); @@ -345,14 +345,14 @@ ThrowCompletionOr<ISODateRecord> regulate_iso_date(GlobalObject& global_object, // This does not change the exposed behavior as the call to IsValidISODate will immediately check that these values are valid ISO // values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check. if (!AK::is_within_range<i32>(year) || !AK::is_within_range<u8>(month) || !AK::is_within_range<u8>(day)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); auto y = static_cast<i32>(year); auto m = static_cast<u8>(month); auto d = static_cast<u8>(day); // b. If IsValidISODate(year, month, day) is false, throw a RangeError exception. if (!is_valid_iso_date(y, m, d)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // c. Return the Record { [[Year]]: year, [[Month]]: month, [[Day]]: day }. return ISODateRecord { .year = y, .month = m, .day = d }; @@ -512,7 +512,7 @@ ThrowCompletionOr<Duration*> difference_temporal_plain_date(GlobalObject& global // 3. If ? CalendarEquals(temporalDate.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception. if (!TRY(calendar_equals(global_object, temporal_date.calendar(), other->calendar()))) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDifferentCalendars); + return vm.throw_completion<RangeError>(ErrorType::TemporalDifferentCalendars); // 4. Let settings be ? GetDifferenceSettings(operation, options, date, ยซ ยป, "day", "day"). auto settings = TRY(get_difference_settings(global_object, operation, options_value, UnitGroup::Date, {}, { "day"sv }, "day"sv)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp index f5f6f56577..84378b3808 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> PlainDateConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainDate"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.PlainDate"); } // 3.1.1 Temporal.PlainDate ( isoYear, isoMonth, isoDay [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate @@ -67,7 +67,7 @@ ThrowCompletionOr<Object*> PlainDateConstructor::construct(FunctionObject& new_t // This does not change the exposed behavior as the call to CreateTemporalDate will immediately check that these values are valid // ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check. if (!AK::is_within_range<i32>(y) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(d)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDate); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDate); // 6. Return ? CreateTemporalDate(y, m, d, calendar, NewTarget). return TRY(create_temporal_date(global_object, y, m, d, *calendar, &new_target)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index 209ec8a254..27044069ce 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -393,7 +393,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with) // 3. If Type(temporalDateLike) is not Object, then if (!temporal_date_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_date_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_like.to_string_without_side_effects()); } // 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateLike). @@ -619,7 +619,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainDate", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainDate", "a primitive value"); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp index 753a72acb5..1e6302a02a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTime.cpp @@ -238,16 +238,16 @@ ThrowCompletionOr<PlainDateTime*> create_temporal_date_time(GlobalObject& global // 3. If IsValidISODate(isoYear, isoMonth, isoDay) is false, throw a RangeError exception. if (!is_valid_iso_date(iso_year, iso_month, iso_day)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime); // 4. If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception. if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime); // 5. If ISODateTimeWithinLimits(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond) is false, then if (!iso_date_time_within_limits(global_object, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond)) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime); } // 6. If newTarget is not present, set newTarget to %Temporal.PlainDateTime%. @@ -422,7 +422,7 @@ ThrowCompletionOr<Duration*> difference_temporal_plain_date_time(GlobalObject& g // 3. If ? CalendarEquals(dateTime.[[Calendar]], other.[[Calendar]]) is false, throw a RangeError exception. if (!TRY(calendar_equals(global_object, date_time.calendar(), other->calendar()))) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDifferentCalendars); + return vm.throw_completion<RangeError>(ErrorType::TemporalDifferentCalendars); // 4. Let settings be ? GetDifferenceSettings(operation, options, datetime, ยซ ยป, "nanosecond", "day"). auto settings = TRY(get_difference_settings(global_object, operation, options_value, UnitGroup::DateTime, {}, { "nanosecond"sv }, "day"sv)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp index 156809f13f..e2d3e0b97b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimeConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> PlainDateTimeConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainDateTime"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.PlainDateTime"); } // 5.1.1 Temporal.PlainDateTime ( isoYear, isoMonth, isoDay [ , hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond [ , calendarLike ] ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime @@ -86,7 +86,7 @@ ThrowCompletionOr<Object*> PlainDateTimeConstructor::construct(FunctionObject& n // ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31, for hours: 0 - 23, for minutes and seconds: 0 - 59, // milliseconds, microseconds, and nanoseconds: 0 - 999) all of which are subsets of this check. if (!AK::is_within_range<i32>(iso_year) || !AK::is_within_range<u8>(iso_month) || !AK::is_within_range<u8>(iso_day) || !AK::is_within_range<u8>(hour) || !AK::is_within_range<u8>(minute) || !AK::is_within_range<u8>(second) || !AK::is_within_range<u16>(millisecond) || !AK::is_within_range<u16>(microsecond) || !AK::is_within_range<u16>(nanosecond)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainDateTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainDateTime); // 12. Return ? CreateTemporalDateTime(isoYear, isoMonth, isoDay, hour, minute, second, millisecond, microsecond, nanosecond, calendar, NewTarget). return TRY(create_temporal_date_time(global_object, iso_year, iso_month, iso_day, hour, minute, second, millisecond, microsecond, nanosecond, *calendar, &new_target)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index b464fa3da3..0e77a336ec 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -365,7 +365,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with) // 3. If Type(temporalDateTimeLike) is not Object, then if (!temporal_date_time_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_date_time_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_date_time_like.to_string_without_side_effects()); } // 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalDateTimeLike). @@ -526,7 +526,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::round) // 3. If roundTo is undefined, then if (vm.argument(0).is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); } Object* round_to; @@ -637,7 +637,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainDateTime", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainDateTime", "a primitive value"); } // 5.3.36 Temporal.PlainDateTime.prototype.toZonedDateTime ( temporalTimeZoneLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tozoneddatetime diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp index fbf8d44b25..1642f71884 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDay.cpp @@ -153,11 +153,11 @@ ThrowCompletionOr<PlainMonthDay*> create_temporal_month_day(GlobalObject& global // 3. If IsValidISODate(referenceISOYear, isoMonth, isoDay) is false, throw a RangeError exception. if (!is_valid_iso_date(reference_iso_year, iso_month, iso_day)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainMonthDay); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay); // 4. If ISODateTimeWithinLimits(referenceISOYear, isoMonth, isoDay, 12, 0, 0, 0, 0, 0) is false, throw a RangeError exception. if (!iso_date_time_within_limits(global_object, reference_iso_year, iso_month, iso_day, 12, 0, 0, 0, 0, 0)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainMonthDay); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay); // 5. If newTarget is not present, set newTarget to %Temporal.PlainMonthDay%. if (!new_target) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp index ba4145c10c..581249b176 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayConstructor.cpp @@ -40,7 +40,7 @@ ThrowCompletionOr<Value> PlainMonthDayConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainMonthDay"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.PlainMonthDay"); } // 10.1.1 Temporal.PlainMonthDay ( isoMonth, isoDay [ , calendarLike [ , referenceISOYear ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday @@ -76,7 +76,7 @@ ThrowCompletionOr<Object*> PlainMonthDayConstructor::construct(FunctionObject& n // This does not change the exposed behavior as the call to CreateTemporalMonthDay will immediately check that these values are valid // ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check. if (!AK::is_within_range<i32>(ref) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(d)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainMonthDay); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay); // 7. Return ? CreateTemporalMonthDay(m, d, calendar, ref, NewTarget). return TRY(create_temporal_month_day(global_object, m, d, *calendar, ref, &new_target)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index cedb15a93b..3a775b77ca 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -95,7 +95,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with) // 3. If Type(temporalMonthDayLike) is not Object, then if (!temporal_month_day_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_month_day_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_month_day_like.to_string_without_side_effects()); } // 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalMonthDayLike). @@ -196,7 +196,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainMonthDay", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainMonthDay", "a primitive value"); } // 10.3.12 Temporal.PlainMonthDay.prototype.toPlainDate ( item ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.toplaindate @@ -213,7 +213,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date) // 3. If Type(item) is not Object, then if (!item.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, item); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, item); } // 4. Let calendar be monthDay.[[Calendar]]. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp index a25e5583a1..309fb75d84 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTime.cpp @@ -123,7 +123,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu auto calendar_identifier = TRY(Value(calendar).to_string(global_object)); if (calendar_identifier != "iso8601"sv) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, calendar_identifier); } // f. Let result be ? ToTemporalTimeRecord(item). @@ -146,7 +146,7 @@ ThrowCompletionOr<PlainTime*> to_temporal_time(GlobalObject& global_object, Valu // d. If result.[[Calendar]] is not one of undefined or "iso8601", then if (result->calendar.has_value() && *result->calendar != "iso8601"sv) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, *result->calendar); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidCalendarIdentifier, *result->calendar); } } @@ -177,7 +177,7 @@ ThrowCompletionOr<TemporalTime> regulate_time(GlobalObject& global_object, doubl // b. If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception. if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime); // c. Return the Record { [[Hour]]: hour, [[Minute]]: minute, [[Second]]: second, [[Millisecond]]: millisecond, [[Microsecond]]: microsecond, [[Nanosecond]]: nanosecond }. return TemporalTime { .hour = static_cast<u8>(hour), .minute = static_cast<u8>(minute), .second = static_cast<u8>(second), .millisecond = static_cast<u16>(millisecond), .microsecond = static_cast<u16>(microsecond), .nanosecond = static_cast<u16>(nanosecond) }; @@ -317,7 +317,7 @@ ThrowCompletionOr<PlainTime*> create_temporal_time(GlobalObject& global_object, // 2. If IsValidTime(hour, minute, second, millisecond, microsecond, nanosecond) is false, throw a RangeError exception. if (!is_valid_time(hour, minute, second, millisecond, microsecond, nanosecond)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime); // 3. If newTarget is not present, set newTarget to %Temporal.PlainTime%. if (!new_target) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp index 0955cc7bf2..34f5feda96 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp @@ -40,7 +40,7 @@ ThrowCompletionOr<Value> PlainTimeConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainTime"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.PlainTime"); } // 4.1.1 Temporal.PlainTime ( [ hour [ , minute [ , second [ , millisecond [ , microsecond [ , nanosecond ] ] ] ] ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime @@ -72,7 +72,7 @@ ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_t // ISO values (for hours: 0 - 23, for minutes and seconds: 0 - 59, milliseconds, microseconds, and nanoseconds: 0 - 999) all of which // are subsets of this check. if (!AK::is_within_range<u8>(hour) || !AK::is_within_range<u8>(minute) || !AK::is_within_range<u8>(second) || !AK::is_within_range<u16>(millisecond) || !AK::is_within_range<u16>(microsecond) || !AK::is_within_range<u16>(nanosecond)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainTime); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainTime); // 8. Return ? CreateTemporalTime(hour, minute, second, millisecond, microsecond, nanosecond, NewTarget). return TRY(create_temporal_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, &new_target)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index dff8a34e91..1e196f8349 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -174,7 +174,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with) // 3. If Type(temporalTimeLike) is not Object, then if (!temporal_time_like_argument.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects()); } auto& temporal_time_like = temporal_time_like_argument.as_object(); @@ -274,7 +274,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::round) // 3. If roundTo is undefined, then if (vm.argument(0).is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); } Object* round_to; @@ -378,7 +378,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_zoned_date_time) // 3. If Type(item) is not Object, then if (!item.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, item); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, item); } // 4. Let temporalDateLike be ? Get(item, "plainDate"). @@ -387,7 +387,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_zoned_date_time) // 5. If temporalDateLike is undefined, then if (temporal_date_like.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.plainDate.as_string()); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, vm.names.plainDate.as_string()); } // 6. Let temporalDate be ? ToTemporalDate(temporalDateLike). @@ -399,7 +399,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_zoned_date_time) // 8. If temporalTimeZoneLike is undefined, then if (temporal_time_zone_like.is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::MissingRequiredProperty, vm.names.timeZone.as_string()); + return vm.throw_completion<TypeError>(ErrorType::MissingRequiredProperty, vm.names.timeZone.as_string()); } // 9. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike). @@ -504,7 +504,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainTime", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainTime", "a primitive value"); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp index a97464d724..62b8064cd8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonth.cpp @@ -101,7 +101,7 @@ ThrowCompletionOr<ISOYearMonth> regulate_iso_year_month(GlobalObject& global_obj // values (for years: -273975 - 273975) which is a subset of this check. // If RegulateISOYearMonth is ever used outside ISOYearMonthFromFields, this may need to be changed. if (!AK::is_within_range<i32>(year)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // a. Set month to the result of clamping month between 1 and 12. month = clamp(month, 1, 12); @@ -118,11 +118,11 @@ ThrowCompletionOr<ISOYearMonth> regulate_iso_year_month(GlobalObject& global_obj // This does not change the exposed behavior as the call to IsValidISOMonth and subsequent call to CreateTemporalDateTime will check // that these values are valid ISO values (for years: -273975 - 273975, for months: 1 - 12) all of which are subsets of this check. if (!AK::is_within_range<i32>(year) || !AK::is_within_range<u8>(month)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // b. If ! IsValidISOMonth(month) is false, throw a RangeError exception. if (!is_valid_iso_month(month)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // c. Return the Record { [[Year]]: year, [[Month]]: month }. return ISOYearMonth { .year = static_cast<i32>(year), .month = static_cast<u8>(month), .reference_iso_day = 0 }; @@ -196,11 +196,11 @@ ThrowCompletionOr<PlainYearMonth*> create_temporal_year_month(GlobalObject& glob // 3. If IsValidISODate(isoYear, isoMonth, referenceISODay) is false, throw a RangeError exception. if (!is_valid_iso_date(iso_year, iso_month, reference_iso_day)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // 4. If ! ISOYearMonthWithinLimits(isoYear, isoMonth) is false, throw a RangeError exception. if (!iso_year_month_within_limits(iso_year, iso_month)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // 5. If newTarget is not present, set newTarget to %Temporal.PlainYearMonth%. if (!new_target) @@ -262,7 +262,7 @@ ThrowCompletionOr<Duration*> difference_temporal_plain_year_month(GlobalObject& // 4. If ? CalendarEquals(calendar, other.[[Calendar]]) is false, throw a RangeError exception. if (!TRY(calendar_equals(global_object, calendar, other->calendar()))) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDifferentCalendars); + return vm.throw_completion<RangeError>(ErrorType::TemporalDifferentCalendars); // 5. Let settings be ? GetDifferenceSettings(operation, options, date, ยซ "week", "day" ยป, "month", "year"). auto settings = TRY(get_difference_settings(global_object, operation, options_value, UnitGroup::Date, { "week"sv, "day"sv }, { "month"sv }, "year"sv)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp index 8c2d70ed6d..f355ea6701 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthConstructor.cpp @@ -42,7 +42,7 @@ ThrowCompletionOr<Value> PlainYearMonthConstructor::call() auto& vm = this->vm(); // 1. If NewTarget is undefined, throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.PlainYearMonth"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.PlainYearMonth"); } // 9.1.1 Temporal.PlainYearMonth ( isoYear, isoMonth [ , calendarLike [ , referenceISODay ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth @@ -78,7 +78,7 @@ ThrowCompletionOr<Object*> PlainYearMonthConstructor::construct(FunctionObject& // This does not change the exposed behavior as the call to CreateTemporalYearMonth will immediately check that these values are valid // ISO values (for years: -273975 - 273975, for months: 1 - 12, for days: 1 - 31) all of which are subsets of this check. if (!AK::is_within_range<i32>(y) || !AK::is_within_range<u8>(m) || !AK::is_within_range<u8>(ref)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidPlainYearMonth); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainYearMonth); // 7. Return ? CreateTemporalYearMonth(y, m, calendar, ref, NewTarget). return TRY(create_temporal_year_month(global_object, y, m, *calendar, ref, &new_target)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 6db9b315e1..9a02780cbc 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -206,7 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with) // 3. If Type(temporalYearMonthLike) is not Object, then if (!temporal_year_month_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_year_month_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_year_month_like.to_string_without_side_effects()); } // 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalYearMonthLike). @@ -363,7 +363,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainYearMonth", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.PlainYearMonth", "a primitive value"); } // 9.3.21 Temporal.PlainYearMonth.prototype.toPlainDate ( item ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.toplaindate @@ -380,7 +380,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date) // 3. If Type(item) is not Object, then if (!item.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, item); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, item); } // 4. Let calendar be yearMonth.[[Calendar]]. diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp index 5e387ab324..f54965a802 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZone.cpp @@ -271,7 +271,7 @@ ThrowCompletionOr<double> parse_time_zone_offset_string(GlobalObject& global_obj // 2. If parseResult is a List of errors, throw a RangeError exception. if (!parse_result.has_value()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidFormat, "TimeZone offset"); + return vm.throw_completion<RangeError>(ErrorType::InvalidFormat, "TimeZone offset"); // 3. Let each of sign, hours, minutes, seconds, and fSeconds be the source text matched by the respective TimeZoneUTCOffsetSign, TimeZoneUTCOffsetHour, TimeZoneUTCOffsetMinute, TimeZoneUTCOffsetSecond, and TimeZoneUTCOffsetFraction Parse Node contained within parseResult, or an empty sequence of code points if not present. auto sign = parse_result->time_zone_utc_offset_sign; @@ -459,7 +459,7 @@ ThrowCompletionOr<Object*> to_temporal_time_zone(GlobalObject& global_object, Va if (!is_valid_time_zone_numeric_utc_offset_syntax(name)) { // i. If IsValidTimeZoneName(name) is false, throw a RangeError exception. if (!is_valid_time_zone_name(name)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneName, name); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneName, name); // ii. Set name to ! CanonicalizeTimeZoneName(name). name = canonicalize_time_zone_name(name); @@ -490,18 +490,18 @@ ThrowCompletionOr<double> get_offset_nanoseconds_for(GlobalObject& global_object // 3. If Type(offsetNanoseconds) is not Number, throw a TypeError exception. if (!offset_nanoseconds_value.is_number()) - return vm.throw_completion<TypeError>(global_object, ErrorType::IsNotA, "Offset nanoseconds value", "number"); + return vm.throw_completion<TypeError>(ErrorType::IsNotA, "Offset nanoseconds value", "number"); // 4. If IsIntegralNumber(offsetNanoseconds) is false, throw a RangeError exception. if (!offset_nanoseconds_value.is_integral_number()) - return vm.throw_completion<RangeError>(global_object, ErrorType::IsNotAn, "Offset nanoseconds value", "integral number"); + return vm.throw_completion<RangeError>(ErrorType::IsNotAn, "Offset nanoseconds value", "integral number"); // 5. Set offsetNanoseconds to โ(offsetNanoseconds). auto offset_nanoseconds = offset_nanoseconds_value.as_double(); // 6. If abs(offsetNanoseconds) > nsPerDay, throw a RangeError exception. if (fabs(offset_nanoseconds) > ns_per_day) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidOffsetNanosecondsValue); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidOffsetNanosecondsValue); // 7. Return offsetNanoseconds. return offset_nanoseconds; @@ -581,7 +581,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ VERIFY(disambiguation == "reject"sv); // d. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDisambiguatePossibleInstantsRejectMoreThanOne); + return vm.throw_completion<RangeError>(ErrorType::TemporalDisambiguatePossibleInstantsRejectMoreThanOne); } // 5. Assert: n = 0. @@ -590,7 +590,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ // 6. If disambiguation is "reject", then if (disambiguation == "reject"sv) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDisambiguatePossibleInstantsRejectZero); + return vm.throw_completion<RangeError>(ErrorType::TemporalDisambiguatePossibleInstantsRejectZero); } // 7. Let epochNanoseconds be GetEpochFromISOParts(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]). @@ -601,7 +601,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ // 9. If ! IsValidEpochNanoseconds(dayBeforeNs) is false, throw a RangeError exception. if (!is_valid_epoch_nanoseconds(*day_before_ns)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 10. Let dayBefore be ! CreateTemporalInstant(dayBeforeNs). auto* day_before = MUST(create_temporal_instant(global_object, *day_before_ns)); @@ -611,7 +611,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ // 12. If ! IsValidEpochNanoseconds(dayAfterNs) is false, throw a RangeError exception. if (!is_valid_epoch_nanoseconds(*day_after_ns)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 13. Let dayAfter be ! CreateTemporalInstant(dayAfterNs). auto* day_after = MUST(create_temporal_instant(global_object, *day_after_ns)); @@ -638,7 +638,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ // d. If possibleInstants is empty, throw a RangeError exception. if (possible_instants_.is_empty()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDisambiguatePossibleInstantsEarlierZero); + return vm.throw_completion<RangeError>(ErrorType::TemporalDisambiguatePossibleInstantsEarlierZero); // e. Return possibleInstants[0]. return possible_instants_[0]; @@ -661,7 +661,7 @@ ThrowCompletionOr<Instant*> disambiguate_possible_instants(GlobalObject& global_ // 23. If n = 0, throw a RangeError exception. if (n == 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDisambiguatePossibleInstantsZero); + return vm.throw_completion<RangeError>(ErrorType::TemporalDisambiguatePossibleInstantsZero); // 24. Return possibleInstants[n - 1]. return possible_instants_[n - 1]; @@ -699,7 +699,7 @@ ThrowCompletionOr<MarkedVector<Instant*>> get_possible_instants_for(GlobalObject // ii. If Type(nextValue) is not Object or nextValue does not have an [[InitializedTemporalInstant]] internal slot, then if (!next_value.is_object() || !is<Instant>(next_value.as_object())) { // 1. Let completion be ThrowCompletion(a newly created TypeError object). - auto completion = vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "Temporal.Instant"); + auto completion = vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "Temporal.Instant"); // 2. Return ? IteratorClose(iteratorRecord, completion). return iterator_close(global_object, iterator, move(completion)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp index eac3857367..e733475a0f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZoneConstructor.cpp @@ -38,7 +38,7 @@ ThrowCompletionOr<Value> TimeZoneConstructor::call() // 1. If NewTarget is undefined, then // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.TimeZone"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.TimeZone"); } // 11.2.1 Temporal.TimeZone ( identifier ), https://tc39.es/proposal-temporal/#sec-temporal.timezone @@ -56,7 +56,7 @@ ThrowCompletionOr<Object*> TimeZoneConstructor::construct(FunctionObject& new_ta // a. If IsValidTimeZoneName(identifier) is false, then if (!is_valid_time_zone_name(identifier)) { // i. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneName, identifier); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneName, identifier); } // b. Set identifier to ! CanonicalizeTimeZoneName(identifier). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index c86d55dbeb..5366748203 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -161,7 +161,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for) for (auto& epoch_nanoseconds : possible_epoch_nanoseconds) { // 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // b. Let instant be ! CreateTemporalInstant(epochNanoseconds). auto* instant = MUST(create_temporal_instant(global_object, *epoch_nanoseconds)); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index 769376fb70..f4293acc4d 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -69,7 +69,7 @@ ThrowCompletionOr<BigInt const*> interpret_iso_date_time_offset(GlobalObject& gl // c. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // d. Return epochNanoseconds. return epoch_nanoseconds; @@ -110,7 +110,7 @@ ThrowCompletionOr<BigInt const*> interpret_iso_date_time_offset(GlobalObject& gl // 9. If offsetOption is "reject", throw a RangeError exception. if (offset_option == "reject"sv) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidZonedDateTimeOffset); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidZonedDateTimeOffset); // 10. Let instant be ? DisambiguatePossibleInstants(possibleInstants, timeZone, dateTime, disambiguation). auto* instant = TRY(disambiguate_possible_instants(global_object, possible_instants, time_zone, *date_time, disambiguation)); @@ -210,7 +210,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(GlobalObject& glob if (!is_valid_time_zone_numeric_utc_offset_syntax(*time_zone_name)) { // i. If IsValidTimeZoneName(timeZoneName) is false, throw a RangeError exception. if (!is_valid_time_zone_name(*time_zone_name)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidTimeZoneName, *time_zone_name); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidTimeZoneName, *time_zone_name); // ii. Set timeZoneName to ! CanonicalizeTimeZoneName(timeZoneName). time_zone_name = canonicalize_time_zone_name(*time_zone_name); @@ -489,7 +489,7 @@ ThrowCompletionOr<NanosecondsToDaysResult> nanoseconds_to_days(GlobalObject& glo // 9. If ! IsValidEpochNanoseconds(โค(endNs)) is false, throw a RangeError exception. if (!is_valid_epoch_nanoseconds(*end_ns_bigint)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidEpochNanoseconds); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 10. Let endInstant be ! CreateTemporalInstant(โค(endNs)). auto* end_instant = MUST(create_temporal_instant(global_object, *end_ns_bigint)); @@ -566,7 +566,7 @@ ThrowCompletionOr<Duration*> difference_temporal_zoned_date_time(GlobalObject& g // 3. If ? CalendarEquals(zonedDateTime.[[Calendar]], other.[[Calendar]]) is false, then if (!TRY(calendar_equals(global_object, zoned_date_time.calendar(), other->calendar()))) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDifferentCalendars); + return vm.throw_completion<RangeError>(ErrorType::TemporalDifferentCalendars); } // 4. Let settings be ? GetDifferenceSettings(operation, options, datetime, ยซ ยป, "nanosecond", "hour"). @@ -589,7 +589,7 @@ ThrowCompletionOr<Duration*> difference_temporal_zoned_date_time(GlobalObject& g // 6. If ? TimeZoneEquals(zonedDateTime.[[TimeZone]], other.[[TimeZone]]) is false, then if (!TRY(time_zone_equals(global_object, zoned_date_time.time_zone(), other->time_zone()))) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalDifferentTimeZones); + return vm.throw_completion<RangeError>(ErrorType::TemporalDifferentTimeZones); } // 7. Let untilOptions be ? MergeLargestUnitOption(settings.[[Options]], settings.[[LargestUnit]]). diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index 4873aa18f4..0ffd136e0f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -44,7 +44,7 @@ ThrowCompletionOr<Value> ZonedDateTimeConstructor::call() // 1. If NewTarget is undefined, then // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Temporal.ZonedDateTime"); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, "Temporal.ZonedDateTime"); } // 6.1.1 Temporal.ZonedDateTime ( epochNanoseconds, timeZoneLike [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime @@ -58,7 +58,7 @@ ThrowCompletionOr<Object*> ZonedDateTimeConstructor::construct(FunctionObject& n // 3. 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); + return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds); // 4. Let timeZone be ? ToTemporalTimeZone(timeZoneLike). auto* time_zone = TRY(to_temporal_time_zone(global_object, vm.argument(1))); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index 4390d0f46e..75696d997c 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -729,7 +729,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with) // 3. If Type(temporalZonedDateTimeLike) is not Object, then if (!temporal_zoned_date_time_like.is_object()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_zoned_date_time_like.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, temporal_zoned_date_time_like.to_string_without_side_effects()); } // 4. Perform ? RejectObjectWithCalendarOrTimeZone(temporalZonedDateTimeLike). @@ -960,7 +960,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::round) // 3. If roundTo is undefined, then if (vm.argument(0).is_undefined()) { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalMissingOptionsObject); + return vm.throw_completion<TypeError>(ErrorType::TemporalMissingOptionsObject); } Object* round_to; @@ -1023,7 +1023,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::round) // 19. If dayLengthNs โค 0, then if (day_length_ns <= 0) { // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalZonedDateTimeRoundZeroOrNegativeLengthDay); + return vm.throw_completion<RangeError>(ErrorType::TemporalZonedDateTimeRoundZeroOrNegativeLengthDay); } // 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], temporalDateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode, dayLengthNs). @@ -1117,7 +1117,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_json) JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::value_of) { // 1. Throw a TypeError exception. - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.ZonedDateTime", "a primitive value"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "Temporal.ZonedDateTime", "a primitive value"); } // 6.3.45 Temporal.ZonedDateTime.prototype.startOfDay ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.startofday diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp index 288566b85d..84c87411fa 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> - * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> + * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -23,7 +23,7 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_from(GlobalObject& global_object, auto* this_object = TRY(typed_array_value.to_object(global_object)); if (!this_object->is_typed_array()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "TypedArray"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "TypedArray"); return static_cast<TypedArrayBase*>(this_object); } @@ -35,7 +35,7 @@ ThrowCompletionOr<void> validate_typed_array(GlobalObject& global_object, TypedA // 1. Perform ? RequireInternalSlot(O, [[TypedArrayName]]). if (!typed_array.is_typed_array()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "TypedArray"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "TypedArray"); // 2. Assert: O has a [[ViewedArrayBuffer]] internal slot. @@ -44,7 +44,7 @@ ThrowCompletionOr<void> validate_typed_array(GlobalObject& global_object, TypedA // 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); return {}; } @@ -62,7 +62,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_array_buffer(GlobalOb // 3. If offset modulo elementSize โ 0, throw a RangeError exception. if (offset % element_size != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayInvalidByteOffset, typed_array.class_name(), element_size, offset); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayInvalidByteOffset, typed_array.class_name(), element_size, offset); size_t new_length { 0 }; @@ -74,7 +74,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_array_buffer(GlobalOb // 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (array_buffer.is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 6. Let bufferByteLength be buffer.[[ArrayBufferByteLength]]. auto buffer_byte_length = array_buffer.byte_length(); @@ -85,12 +85,12 @@ static ThrowCompletionOr<void> initialize_typed_array_from_array_buffer(GlobalOb if (length.is_undefined()) { // a. If bufferByteLength modulo elementSize โ 0, throw a RangeError exception. if (buffer_byte_length % element_size != 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayInvalidBufferLength, typed_array.class_name(), element_size, buffer_byte_length); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayInvalidBufferLength, typed_array.class_name(), element_size, buffer_byte_length); // b. Let newByteLength be bufferByteLength - offset. // c. If newByteLength < 0, throw a RangeError exception. if (offset > buffer_byte_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOutOfRangeByteOffset, offset, buffer_byte_length); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOutOfRangeByteOffset, offset, buffer_byte_length); new_byte_length = buffer_byte_length; new_byte_length -= offset; } @@ -105,14 +105,14 @@ static ThrowCompletionOr<void> initialize_typed_array_from_array_buffer(GlobalOb new_byte_end += offset; if (new_byte_end.has_overflow()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); if (new_byte_end.value() > buffer_byte_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOutOfRangeByteOffsetOrLength, offset, new_byte_end.value(), buffer_byte_length); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOutOfRangeByteOffsetOrLength, offset, new_byte_end.value(), buffer_byte_length); } if (new_byte_length.has_overflow()) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); // 9. Set O.[[ViewedArrayBuffer]] to buffer. typed_array.set_viewed_array_buffer(&array_buffer); @@ -142,7 +142,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(GlobalObj // 2. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. if (src_data->is_detached()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.template throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 3. Let elementType be TypedArrayElementType(O). // 4. Let elementSize be TypedArrayElementSize(O). @@ -162,7 +162,7 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(GlobalObj Checked<size_t> byte_length = element_size; byte_length *= element_length; if (byte_length.has_overflow()) - return vm.template throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.template throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); ArrayBuffer* data = nullptr; @@ -178,11 +178,11 @@ static ThrowCompletionOr<void> initialize_typed_array_from_typed_array(GlobalObj // b. If IsDetachedBuffer(srcData) is true, throw a TypeError exception. if (src_data->is_detached()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.template throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // c. If srcArray.[[ContentType]] โ O.[[ContentType]], throw a TypeError exception. if (src_array.content_type() != dest_array.content_type()) - return vm.template throw_completion<TypeError>(global_object, ErrorType::TypedArrayContentTypeMismatch, dest_array.class_name(), src_array.class_name()); + return vm.template throw_completion<TypeError>(ErrorType::TypedArrayContentTypeMismatch, dest_array.class_name(), src_array.class_name()); // d. Let srcByteIndex be srcByteOffset. u64 src_byte_index = src_byte_offset; @@ -233,14 +233,14 @@ static ThrowCompletionOr<void> allocate_typed_array_buffer(GlobalObject& global_ // Enforce 2GB "Excessive Length" limit if (length > NumericLimits<i32>::max() / sizeof(T)) - return vm.template throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.template throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); // 1. Assert: O.[[ViewedArrayBuffer]] is undefined. // 2. Let elementSize be TypedArrayElementSize(O). auto element_size = typed_array.element_size(); if (Checked<size_t>::multiplication_would_overflow(element_size, length)) - return vm.template throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.template throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); // 3. Let byteLength be elementSize ร length. auto byte_length = element_size * length; @@ -332,7 +332,7 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_create(GlobalObject& global_objec // 2. Perform ? ValidateTypedArray(newTypedArray). if (!new_typed_array->is_typed_array()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, "TypedArray"); + return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, "TypedArray"); auto& typed_array = *static_cast<TypedArrayBase*>(new_typed_array); TRY(validate_typed_array(global_object, typed_array)); @@ -340,7 +340,7 @@ ThrowCompletionOr<TypedArrayBase*> typed_array_create(GlobalObject& global_objec if (first_argument.has_value() && first_argument->is_number()) { // a. If newTypedArray.[[ArrayLength]] < โ(argumentList[0]), throw a TypeError exception. if (typed_array.array_length() < first_argument->as_double()) - return vm.throw_completion<TypeError>(global_object, ErrorType::InvalidLength, "typed array"); + return vm.throw_completion<TypeError>(ErrorType::InvalidLength, "typed array"); } // 4. Return newTypedArray. @@ -378,7 +378,7 @@ ThrowCompletionOr<double> compare_typed_array_elements(GlobalObject& global_obje // b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (buffer.is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // c. If v is NaN, return +0๐ฝ. if (value_number.is_nan()) @@ -512,7 +512,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor) ThrowCompletionOr<Value> ConstructorName::call() \ { \ auto& vm = this->vm(); \ - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.ClassName); \ } \ \ /* 23.2.5.1 TypedArray ( ...args ), https://tc39.es/ecma262/#sec-typedarray */ \ @@ -552,16 +552,16 @@ void TypedArrayBase::visit_edges(Visitor& visitor) auto error = array_length_or_error.release_error(); \ if (error.value()->is_object() && is<RangeError>(error.value()->as_object())) { \ /* Re-throw more specific RangeError */ \ - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); \ + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \ } \ return error; \ } \ auto array_length = array_length_or_error.release_value(); \ if (array_length > NumericLimits<i32>::max() / sizeof(Type)) \ - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); \ + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \ /* FIXME: What is the best/correct behavior here? */ \ if (Checked<u32>::multiplication_would_overflow(array_length, sizeof(Type))) \ - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidLength, "typed array"); \ + return vm.throw_completion<RangeError>(ErrorType::InvalidLength, "typed array"); \ return TRY(ClassName::create(realm, array_length, new_target)); \ } diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp index 4ba482655d..21b4292994 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayConstructor.cpp @@ -47,7 +47,7 @@ ThrowCompletionOr<Value> TypedArrayConstructor::call() // 23.2.1.1 %TypedArray% ( ), https://tc39.es/ecma262/#sec-%typedarray% ThrowCompletionOr<Object*> TypedArrayConstructor::construct(FunctionObject&) { - return vm().throw_completion<TypeError>(global_object(), ErrorType::ClassIsAbstract, "TypedArray"); + return vm().throw_completion<TypeError>(ErrorType::ClassIsAbstract, "TypedArray"); } // 23.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ), https://tc39.es/ecma262/#sec-%typedarray%.from @@ -55,13 +55,13 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::from) { auto constructor = vm.this_value(global_object); if (!constructor.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); FunctionObject* map_fn = nullptr; if (!vm.argument(1).is_undefined()) { auto callback = vm.argument(1); if (!callback.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_string_without_side_effects()); map_fn = &callback.as_function(); } @@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayConstructor::of) auto length = vm.argument_count(); auto constructor = vm.this_value(global_object); if (!constructor.is_constructor()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAConstructor, constructor.to_string_without_side_effects()); MarkedVector<Value> arguments(vm.heap()); arguments.append(Value(length)); auto new_object = TRY(typed_array_create(global_object, constructor.as_function(), move(arguments))); diff --git a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp index fafaf7ead1..bf5100e3a1 100644 --- a/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/TypedArrayPrototype.cpp @@ -90,10 +90,10 @@ static ThrowCompletionOr<FunctionObject*> callback_from_args(GlobalObject& globa { auto& vm = global_object.vm(); if (vm.argument_count() < 1) - return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayPrototypeOneArg, name); + return vm.throw_completion<TypeError>(ErrorType::TypedArrayPrototypeOneArg, name); auto callback = vm.argument(0); if (!callback.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, callback.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, callback.to_string_without_side_effects()); return &callback.as_function(); } @@ -158,7 +158,7 @@ static ThrowCompletionOr<TypedArrayBase*> typed_array_species_create(GlobalObjec // 4. Assert: result has [[TypedArrayName]] and [[ContentType]] internal slots. // 5. If result.[[ContentType]] โ exemplar.[[ContentType]], throw a TypeError exception. if (result->content_type() != exemplar.content_type()) - return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayContentTypeMismatch, result->class_name(), exemplar.class_name()); + return vm.throw_completion<TypeError>(ErrorType::TypedArrayContentTypeMismatch, result->class_name(), exemplar.class_name()); // 6. Return result. return result; @@ -287,7 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::copy_within) // c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. if (buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // d. Let elementSize be TypedArrayElementSize(O). auto element_size = typed_array->element_size(); @@ -444,7 +444,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::fill) final = min(relative_end, length); if (typed_array->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); for (; k < final; ++k) TRY(typed_array->set(k, value, Object::ShouldThrowExceptions::Yes)); @@ -798,7 +798,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::reduce) auto* callback_function = TRY(callback_from_args(global_object, vm.names.reduce.as_string())); if (length == 0 && vm.argument_count() <= 1) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); u32 k = 0; Value accumulator; @@ -828,7 +828,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::reduce_right) auto* callback_function = TRY(callback_from_args(global_object, vm.names.reduce.as_string())); if (length == 0 && vm.argument_count() <= 1) - return vm.throw_completion<TypeError>(global_object, ErrorType::ReduceNoInitial); + return vm.throw_completion<TypeError>(ErrorType::ReduceNoInitial); i32 k = (i32)length - 1; Value accumulator; @@ -898,7 +898,7 @@ static ThrowCompletionOr<void> set_typed_array_from_typed_array(GlobalObject& gl // 2. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. if (target_buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 3. Let targetLength be target.[[ArrayLength]]. auto target_length = target.array_length(); @@ -908,7 +908,7 @@ static ThrowCompletionOr<void> set_typed_array_from_typed_array(GlobalObject& gl // 5. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. if (source_buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 6. Let targetType be TypedArrayElementType(target). // 7. Let targetElementSize be TypedArrayElementSize(target). @@ -929,17 +929,17 @@ static ThrowCompletionOr<void> set_typed_array_from_typed_array(GlobalObject& gl // 13. If targetOffset is +โ, throw a RangeError exception. if (isinf(target_offset)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayInvalidTargetOffset, "finite"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayInvalidTargetOffset, "finite"); // 14. If srcLength + targetOffset > targetLength, throw a RangeError exception. Checked<size_t> checked = source_length; checked += static_cast<u32>(target_offset); if (checked.has_overflow() || checked.value() > target_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOverflowOrOutOfBounds, "target length"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOverflowOrOutOfBounds, "target length"); // 15. If target.[[ContentType]] โ source.[[ContentType]], throw a TypeError exception. if (target.content_type() != source.content_type()) - return vm.throw_completion<TypeError>(global_object, ErrorType::TypedArrayInvalidCopy, target.class_name(), source.class_name()); + return vm.throw_completion<TypeError>(ErrorType::TypedArrayInvalidCopy, target.class_name(), source.class_name()); // FIXME: 16. If both IsSharedArrayBuffer(srcBuffer) and IsSharedArrayBuffer(targetBuffer) are true, then // FIXME: a. If srcBuffer.[[ArrayBufferData]] and targetBuffer.[[ArrayBufferData]] are the same Shared Data Block values, let same be true; else let same be false. @@ -970,7 +970,7 @@ static ThrowCompletionOr<void> set_typed_array_from_typed_array(GlobalObject& gl checked_target_byte_index *= target_element_size; checked_target_byte_index += target_byte_offset; if (checked_target_byte_index.has_overflow()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOverflow, "target byte index"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOverflow, "target byte index"); auto target_byte_index = checked_target_byte_index.value(); // 21. Let limit be targetByteIndex + targetElementSize ร srcLength. @@ -978,7 +978,7 @@ static ThrowCompletionOr<void> set_typed_array_from_typed_array(GlobalObject& gl checked_limit *= target_element_size; checked_limit += target_byte_index; if (checked_limit.has_overflow()) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOverflow, "target limit"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOverflow, "target limit"); auto limit = checked_limit.value(); // 22. If srcType is the same as targetType, then @@ -1020,7 +1020,7 @@ static ThrowCompletionOr<void> set_typed_array_from_array_like(GlobalObject& glo // 2. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. if (target_buffer->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // 3. Let targetLength be target.[[ArrayLength]]. auto target_length = target.array_length(); @@ -1033,13 +1033,13 @@ static ThrowCompletionOr<void> set_typed_array_from_array_like(GlobalObject& glo // 6. If targetOffset is +โ, throw a RangeError exception. if (isinf(target_offset)) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayInvalidTargetOffset, "finite"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayInvalidTargetOffset, "finite"); // 7. If srcLength + targetOffset > targetLength, throw a RangeError exception. Checked<size_t> checked = source_length; checked += static_cast<u32>(target_offset); if (checked.has_overflow() || checked.value() > target_length) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayOverflowOrOutOfBounds, "target length"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayOverflowOrOutOfBounds, "target length"); // 8. Let k be 0. size_t k = 0; @@ -1085,7 +1085,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::set) // 5. If targetOffset < 0, throw a RangeError exception. if (target_offset < 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::TypedArrayInvalidTargetOffset, "positive"); + return vm.throw_completion<RangeError>(ErrorType::TypedArrayInvalidTargetOffset, "positive"); // 6. If source is an Object that has a [[TypedArrayName]] internal slot, then if (source.is_object() && is<TypedArrayBase>(source.as_object())) { @@ -1164,7 +1164,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::slice) if (count > 0) { // a. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. if (typed_array->viewed_array_buffer()->is_detached()) - return vm.throw_completion<TypeError>(global_object, ErrorType::DetachedArrayBuffer); + return vm.throw_completion<TypeError>(ErrorType::DetachedArrayBuffer); // b. Let srcType be TypedArrayElementType(O). // c. Let targetType be TypedArrayElementType(A). @@ -1261,7 +1261,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::sort) // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. auto compare_fn = vm.argument(0); if (!compare_fn.is_undefined() && !compare_fn.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, compare_fn.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, compare_fn.to_string_without_side_effects()); // 2. Let obj be the this value. // 3. Perform ? ValidateTypedArray(obj). @@ -1519,7 +1519,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::to_sorted) auto comparefn = vm.argument(0); // 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. if (!comparefn.is_undefined() && !comparefn.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, comparefn); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, comparefn); // 2. Let O be the this value. auto* object = TRY(vm.this_value(global_object).to_object(global_object)); @@ -1592,7 +1592,7 @@ JS_DEFINE_NATIVE_FUNCTION(TypedArrayPrototype::with) // 9. If ! IsValidIntegerIndex(O, ๐ฝ(actualIndex)) is false, throw a RangeError exception. if (!is_valid_integer_index(*typed_array, CanonicalIndex(CanonicalIndex::Type::Index, actual_index))) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidIndex); + return vm.throw_completion<RangeError>(ErrorType::InvalidIndex); // 10. Let A be ? TypedArrayCreateSameType(O, ยซ ๐ฝ(len) ยป). MarkedVector<Value> arguments(vm.heap()); diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index bfabdd1551..231e76bc42 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -911,12 +911,10 @@ ThrowCompletionOr<NonnullRefPtr<Module>> VM::resolve_imported_module(ScriptOrMod dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] reading and parsing module {}", filename); - auto& global_object = current_realm()->global_object(); - auto file_or_error = Core::File::open(filename, Core::OpenMode::ReadOnly); if (file_or_error.is_error()) { - return throw_completion<SyntaxError>(global_object, ErrorType::ModuleNotFound, module_request.module_specifier); + return throw_completion<SyntaxError>(ErrorType::ModuleNotFound, module_request.module_specifier); } // FIXME: Don't read the file in one go. @@ -937,7 +935,7 @@ ThrowCompletionOr<NonnullRefPtr<Module>> VM::resolve_imported_module(ScriptOrMod if (module_or_errors.is_error()) { VERIFY(module_or_errors.error().size() > 0); - return throw_completion<SyntaxError>(global_object, module_or_errors.error().first().to_string()); + return throw_completion<SyntaxError>(module_or_errors.error().first().to_string()); } return module_or_errors.release_value(); }()); diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index 5f3601fef1..cc9ab74bb9 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -90,11 +90,11 @@ public: m_execution_context_stack.append(&context); } - ThrowCompletionOr<void> push_execution_context(ExecutionContext& context, GlobalObject& global_object) + ThrowCompletionOr<void> push_execution_context(ExecutionContext& context, GlobalObject&) { // Ensure we got some stack space left, so the next function call doesn't kill us. if (did_reach_stack_space_limit()) - return throw_completion<InternalError>(global_object, ErrorType::CallStackSizeExceeded); + return throw_completion<InternalError>(ErrorType::CallStackSizeExceeded); m_execution_context_stack.append(&context); return {}; } @@ -163,16 +163,16 @@ public: // 5.2.3.2 Throw an Exception, https://tc39.es/ecma262/#sec-throw-an-exception template<typename T, typename... Args> - Completion throw_completion(GlobalObject& global_object, Args&&... args) + Completion throw_completion(Args&&... args) { - auto& realm = realm_from_global_object(global_object); + auto& realm = *current_realm(); return JS::throw_completion(T::create(realm, forward<Args>(args)...)); } template<typename T, typename... Args> - Completion throw_completion(GlobalObject& global_object, ErrorType type, Args&&... args) + Completion throw_completion(ErrorType type, Args&&... args) { - return throw_completion<T>(global_object, String::formatted(type.message(), forward<Args>(args)...)); + return throw_completion<T>(String::formatted(type.message(), forward<Args>(args)...)); } Value construct(FunctionObject&, FunctionObject& new_target, Optional<MarkedVector<Value>> arguments); diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 8de73e96ab..4f5d61c8da 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -207,7 +207,7 @@ ThrowCompletionOr<bool> Value::is_array(GlobalObject& global_object) const if (is<ProxyObject>(object)) { auto& proxy = static_cast<ProxyObject const&>(object); if (proxy.is_revoked()) - return vm.throw_completion<TypeError>(global_object, ErrorType::ProxyRevoked); + return vm.throw_completion<TypeError>(ErrorType::ProxyRevoked); return Value(&proxy.target()).is_array(global_object); } return false; @@ -353,7 +353,7 @@ ThrowCompletionOr<String> Value::to_string(GlobalObject& global_object) const case STRING_TAG: return as_string().string(); case SYMBOL_TAG: - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "symbol", "string"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "symbol", "string"); case BIGINT_TAG: return as_bigint().big_integer().to_base(10); case OBJECT_TAG: { @@ -430,7 +430,7 @@ ThrowCompletionOr<Value> Value::to_primitive(GlobalObject& global_object, Prefer auto result = TRY(call(global_object, *to_primitive_method, *this, js_string(vm, hint))); if (!result.is_object()) return result; - return vm.throw_completion<TypeError>(global_object, ErrorType::ToPrimitiveReturnedObject, to_string_without_side_effects(), hint); + return vm.throw_completion<TypeError>(ErrorType::ToPrimitiveReturnedObject, to_string_without_side_effects(), hint); } if (preferred_type == PreferredType::Default) preferred_type = PreferredType::Number; @@ -450,7 +450,7 @@ ThrowCompletionOr<Object*> Value::to_object(GlobalObject& global_object) const switch (m_value.tag) { case UNDEFINED_TAG: case NULL_TAG: - return global_object.vm().throw_completion<TypeError>(global_object, ErrorType::ToObjectNullOrUndefined); + return global_object.vm().throw_completion<TypeError>(ErrorType::ToObjectNullOrUndefined); case BOOLEAN_TAG: return BooleanObject::create(realm, as_bool()); case STRING_TAG: @@ -509,9 +509,9 @@ ThrowCompletionOr<Value> Value::to_number(GlobalObject& global_object) const return Value(parsed_double); } case SYMBOL_TAG: - return global_object.vm().throw_completion<TypeError>(global_object, ErrorType::Convert, "symbol", "number"); + return global_object.vm().throw_completion<TypeError>(ErrorType::Convert, "symbol", "number"); case BIGINT_TAG: - return global_object.vm().throw_completion<TypeError>(global_object, ErrorType::Convert, "BigInt", "number"); + return global_object.vm().throw_completion<TypeError>(ErrorType::Convert, "BigInt", "number"); case OBJECT_TAG: { auto primitive = TRY(to_primitive(global_object, PreferredType::Number)); return primitive.to_number(global_object); @@ -529,13 +529,13 @@ ThrowCompletionOr<BigInt*> Value::to_bigint(GlobalObject& global_object) const VERIFY(!primitive.is_empty()); if (primitive.is_number()) - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "number", "BigInt"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "number", "BigInt"); switch (primitive.m_value.tag) { case UNDEFINED_TAG: - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "undefined", "BigInt"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "undefined", "BigInt"); case NULL_TAG: - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "null", "BigInt"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "null", "BigInt"); case BOOLEAN_TAG: { auto value = primitive.as_bool() ? 1 : 0; return js_bigint(vm, Crypto::SignedBigInteger { value }); @@ -548,13 +548,13 @@ ThrowCompletionOr<BigInt*> Value::to_bigint(GlobalObject& global_object) const // 2. If n is undefined, throw a SyntaxError exception. if (!bigint.has_value()) - return vm.throw_completion<SyntaxError>(global_object, ErrorType::BigIntInvalidValue, primitive); + return vm.throw_completion<SyntaxError>(ErrorType::BigIntInvalidValue, primitive); // 3. Return n. return bigint.release_value(); } case SYMBOL_TAG: - return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "symbol", "BigInt"); + return vm.throw_completion<TypeError>(ErrorType::Convert, "symbol", "BigInt"); default: VERIFY_NOT_REACHED(); } @@ -804,10 +804,10 @@ ThrowCompletionOr<size_t> Value::to_index(GlobalObject& global_object) const return 0; auto integer_index = TRY(to_integer_or_infinity(global_object)); if (integer_index < 0) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidIndex); + return vm.throw_completion<RangeError>(ErrorType::InvalidIndex); auto index = MUST(Value(integer_index).to_length(global_object)); if (integer_index != index) - return vm.throw_completion<RangeError>(global_object, ErrorType::InvalidIndex); + return vm.throw_completion<RangeError>(ErrorType::InvalidIndex); return index; } @@ -883,7 +883,7 @@ ThrowCompletionOr<FunctionObject*> Value::get_method(GlobalObject& global_object // 4. If IsCallable(func) is false, throw a TypeError exception. if (!function.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, function.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, function.to_string_without_side_effects()); // 5. Return func. return &function.as_function(); @@ -950,7 +950,7 @@ ThrowCompletionOr<Value> bitwise_and(GlobalObject& global_object, Value lhs, Val } if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_and(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise AND"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "bitwise AND"); } // 13.12 Binary Bitwise Operators, https://tc39.es/ecma262/#sec-binary-bitwise-operators @@ -970,7 +970,7 @@ ThrowCompletionOr<Value> bitwise_or(GlobalObject& global_object, Value lhs, Valu } if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_or(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise OR"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "bitwise OR"); } // 13.12 Binary Bitwise Operators, https://tc39.es/ecma262/#sec-binary-bitwise-operators @@ -990,7 +990,7 @@ ThrowCompletionOr<Value> bitwise_xor(GlobalObject& global_object, Value lhs, Val } if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().bitwise_xor(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "bitwise XOR"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "bitwise XOR"); } // 13.5.6 Bitwise NOT Operator ( ~ ), https://tc39.es/ecma262/#sec-bitwise-not-operator @@ -1049,7 +1049,7 @@ ThrowCompletionOr<Value> left_shift(GlobalObject& global_object, Value lhs, Valu else return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(multiplier_divisor))); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "left-shift"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "left-shift"); } // 13.9.2 The Signed Right Shift Operator ( >> ), https://tc39.es/ecma262/#sec-signed-right-shift-operator @@ -1072,7 +1072,7 @@ ThrowCompletionOr<Value> right_shift(GlobalObject& global_object, Value lhs, Val rhs_negated.negate(); return left_shift(global_object, lhs, js_bigint(vm, rhs_negated)); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "right-shift"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "right-shift"); } // 13.9.3 The Unsigned Right Shift Operator ( >>> ), https://tc39.es/ecma262/#sec-unsigned-right-shift-operator @@ -1091,7 +1091,7 @@ ThrowCompletionOr<Value> unsigned_right_shift(GlobalObject& global_object, Value auto rhs_u32 = MUST(rhs_numeric.to_u32(global_object)) % 32; return Value(lhs_u32 >> rhs_u32); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperator, "unsigned right-shift"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperator, "unsigned right-shift"); } // 13.8.1 The Addition Operator ( + ), https://tc39.es/ecma262/#sec-addition-operator-plus @@ -1123,7 +1123,7 @@ ThrowCompletionOr<Value> add(GlobalObject& global_object, Value lhs, Value rhs) return Value(lhs_numeric.as_double() + rhs_numeric.as_double()); if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().plus(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "addition"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "addition"); } // 13.8.2 The Subtraction Operator ( - ), https://tc39.es/ecma262/#sec-subtraction-operator-minus @@ -1140,7 +1140,7 @@ ThrowCompletionOr<Value> sub(GlobalObject& global_object, Value lhs, Value rhs) } if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().minus(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "subtraction"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "subtraction"); } // 13.7 Multiplicative Operators, https://tc39.es/ecma262/#sec-multiplicative-operators @@ -1153,7 +1153,7 @@ ThrowCompletionOr<Value> mul(GlobalObject& global_object, Value lhs, Value rhs) return Value(lhs_numeric.as_double() * rhs_numeric.as_double()); if (both_bigint(lhs_numeric, rhs_numeric)) return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().multiplied_by(rhs_numeric.as_bigint().big_integer()))); - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "multiplication"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "multiplication"); } // 13.7 Multiplicative Operators, https://tc39.es/ecma262/#sec-multiplicative-operators @@ -1166,10 +1166,10 @@ ThrowCompletionOr<Value> div(GlobalObject& global_object, Value lhs, Value rhs) return Value(lhs_numeric.as_double() / rhs_numeric.as_double()); if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer() == BIGINT_ZERO) - return vm.throw_completion<RangeError>(global_object, ErrorType::DivisionByZero); + return vm.throw_completion<RangeError>(ErrorType::DivisionByZero); return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).quotient)); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "division"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "division"); } // 13.7 Multiplicative Operators, https://tc39.es/ecma262/#sec-multiplicative-operators @@ -1188,10 +1188,10 @@ ThrowCompletionOr<Value> mod(GlobalObject& global_object, Value lhs, Value rhs) } if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer() == BIGINT_ZERO) - return vm.throw_completion<RangeError>(global_object, ErrorType::DivisionByZero); + return vm.throw_completion<RangeError>(ErrorType::DivisionByZero); return Value(js_bigint(vm, lhs_numeric.as_bigint().big_integer().divided_by(rhs_numeric.as_bigint().big_integer()).remainder)); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "modulo"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "modulo"); } static Value exp_double(Value base, Value exponent) @@ -1256,16 +1256,16 @@ ThrowCompletionOr<Value> exp(GlobalObject& global_object, Value lhs, Value rhs) return exp_double(lhs_numeric, rhs_numeric); if (both_bigint(lhs_numeric, rhs_numeric)) { if (rhs_numeric.as_bigint().big_integer().is_negative()) - return vm.throw_completion<RangeError>(global_object, ErrorType::NegativeExponent); + return vm.throw_completion<RangeError>(ErrorType::NegativeExponent); return Value(js_bigint(vm, Crypto::NumberTheory::Power(lhs_numeric.as_bigint().big_integer(), rhs_numeric.as_bigint().big_integer()))); } - return vm.throw_completion<TypeError>(global_object, ErrorType::BigIntBadOperatorOtherType, "exponentiation"); + return vm.throw_completion<TypeError>(ErrorType::BigIntBadOperatorOtherType, "exponentiation"); } ThrowCompletionOr<Value> in(GlobalObject& global_object, Value lhs, Value rhs) { if (!rhs.is_object()) - return global_object.vm().throw_completion<TypeError>(global_object, ErrorType::InOperatorWithObject); + return global_object.vm().throw_completion<TypeError>(ErrorType::InOperatorWithObject); auto lhs_property_key = TRY(lhs.to_property_key(global_object)); return Value(TRY(rhs.as_object().has_property(lhs_property_key))); } @@ -1275,14 +1275,14 @@ ThrowCompletionOr<Value> instance_of(GlobalObject& global_object, Value lhs, Val { auto& vm = global_object.vm(); if (!rhs.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, rhs.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, rhs.to_string_without_side_effects()); auto has_instance_method = TRY(rhs.get_method(global_object, *vm.well_known_symbol_has_instance())); if (has_instance_method) { auto has_instance_result = TRY(call(global_object, *has_instance_method, rhs, lhs)); return Value(has_instance_result.to_boolean()); } if (!rhs.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, rhs.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, rhs.to_string_without_side_effects()); return TRY(ordinary_has_instance(global_object, lhs, rhs)); } @@ -1305,7 +1305,7 @@ ThrowCompletionOr<Value> ordinary_has_instance(GlobalObject& global_object, Valu Object* lhs_object = &lhs.as_object(); auto rhs_prototype = TRY(rhs_function.get(vm.names.prototype)); if (!rhs_prototype.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::InstanceOfOperatorBadPrototype, rhs.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::InstanceOfOperatorBadPrototype, rhs.to_string_without_side_effects()); while (true) { lhs_object = TRY(lhs_object->internal_get_prototype_of()); if (!lhs_object) @@ -1593,7 +1593,7 @@ ThrowCompletionOr<Value> Value::invoke_internal(GlobalObject& global_object, Pro auto& vm = global_object.vm(); auto property = TRY(get(global_object, property_key)); if (!property.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, property.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, property.to_string_without_side_effects()); return call(global_object, property.as_function(), *this, move(arguments)); } diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp index fb8aa0ea63..eaf8965333 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapConstructor.cpp @@ -33,7 +33,7 @@ void WeakMapConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> WeakMapConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.WeakMap); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.WeakMap); } // 24.3.1.1 WeakMap ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakmap-iterable @@ -49,11 +49,11 @@ ThrowCompletionOr<Object*> WeakMapConstructor::construct(FunctionObject& new_tar auto adder = TRY(weak_map->get(vm.names.set)); if (!adder.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, "'set' property of WeakMap"); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, "'set' property of WeakMap"); (void)TRY(get_iterator_values(global_object, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { if (!iterator_value.is_object()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); + return vm.throw_completion<TypeError>(ErrorType::NotAnObject, String::formatted("Iterator value {}", iterator_value.to_string_without_side_effects())); auto key = TRY(iterator_value.as_object().get(0)); auto value = TRY(iterator_value.as_object().get(1)); diff --git a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp index b87bd6402b..ce8004e230 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakMapPrototype.cpp @@ -72,7 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::set) auto* weak_map = TRY(typed_this_object(global_object)); auto value = vm.argument(0); if (!can_be_held_weakly(value)) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, value.to_string_without_side_effects()); weak_map->values().set(&value.as_cell(), vm.argument(1)); return weak_map; } diff --git a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp index 5871149ec9..753acdec8c 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakRefConstructor.cpp @@ -32,7 +32,7 @@ void WeakRefConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> WeakRefConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.WeakRef); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.WeakRef); } // 26.1.1.1 WeakRef ( target ), https://tc39.es/ecma262/#sec-weak-ref-target @@ -43,7 +43,7 @@ ThrowCompletionOr<Object*> WeakRefConstructor::construct(FunctionObject& new_tar auto target = vm.argument(0); if (!can_be_held_weakly(target)) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, target.to_string_without_side_effects()); if (target.is_object()) return TRY(ordinary_create_from_constructor<WeakRef>(global_object, new_target, &GlobalObject::weak_ref_prototype, target.as_object())); diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp index 51b4725c16..ace231b621 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetConstructor.cpp @@ -33,7 +33,7 @@ void WeakSetConstructor::initialize(Realm& realm) ThrowCompletionOr<Value> WeakSetConstructor::call() { auto& vm = this->vm(); - return vm.throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, vm.names.WeakSet); + return vm.throw_completion<TypeError>(ErrorType::ConstructorWithoutNew, vm.names.WeakSet); } // 24.4.1.1 WeakSet ( [ iterable ] ), https://tc39.es/ecma262/#sec-weakset-iterable @@ -49,7 +49,7 @@ ThrowCompletionOr<Object*> WeakSetConstructor::construct(FunctionObject& new_tar auto adder = TRY(weak_set->get(vm.names.add)); if (!adder.is_function()) - return vm.throw_completion<TypeError>(global_object, ErrorType::NotAFunction, "'add' property of WeakSet"); + return vm.throw_completion<TypeError>(ErrorType::NotAFunction, "'add' property of WeakSet"); (void)TRY(get_iterator_values(global_object, vm.argument(0), [&](Value iterator_value) -> Optional<Completion> { TRY(JS::call(global_object, adder.as_function(), weak_set, iterator_value)); diff --git a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp index 90e0b6ba99..0fe40d74b1 100644 --- a/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/WeakSetPrototype.cpp @@ -36,7 +36,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add) auto* weak_set = TRY(typed_this_object(global_object)); auto value = vm.argument(0); if (!can_be_held_weakly(value)) - return vm.throw_completion<TypeError>(global_object, ErrorType::CannotBeHeldWeakly, value.to_string_without_side_effects()); + return vm.throw_completion<TypeError>(ErrorType::CannotBeHeldWeakly, value.to_string_without_side_effects()); weak_set->values().set(&value.as_cell(), AK::HashSetExistingEntryBehavior::Keep); return weak_set; } diff --git a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp index fe57e04f50..1149e1b86c 100644 --- a/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/WrappedFunction.cpp @@ -29,7 +29,7 @@ ThrowCompletionOr<WrappedFunction*> WrappedFunction::create(Realm& realm, Realm& // 8. If result is an Abrupt Completion, throw a TypeError exception. if (result.is_throw_completion()) - return vm.throw_completion<TypeError>(realm.global_object(), ErrorType::WrappedFunctionCopyNameAndLengthThrowCompletion); + return vm.throw_completion<TypeError>(ErrorType::WrappedFunctionCopyNameAndLengthThrowCompletion); // 9. Return wrapped. return wrapped; @@ -126,7 +126,7 @@ ThrowCompletionOr<Value> ordinary_wrapped_function_call(WrappedFunction const& f // 11. Else, else { // a. Throw a TypeError exception. - return vm.throw_completion<TypeError>(caller_realm->global_object(), ErrorType::WrappedFunctionCallThrowCompletion); + return vm.throw_completion<TypeError>(ErrorType::WrappedFunctionCallThrowCompletion); } // NOTE: Also see "Editor's Note" in the spec regarding the TypeError above. diff --git a/Userland/Libraries/LibJS/SourceTextModule.cpp b/Userland/Libraries/LibJS/SourceTextModule.cpp index 05783fd82d..f00a6bbc34 100644 --- a/Userland/Libraries/LibJS/SourceTextModule.cpp +++ b/Userland/Libraries/LibJS/SourceTextModule.cpp @@ -311,7 +311,7 @@ ThrowCompletionOr<void> SourceTextModule::initialize_environment(VM& vm) auto resolution = TRY(resolve_export(vm, entry.export_name)); // b. If resolution is null or ambiguous, throw a SyntaxError exception. if (!resolution.is_valid()) - return vm.throw_completion<SyntaxError>(realm().global_object(), ErrorType::InvalidOrAmbiguousExportEntry, entry.export_name); + return vm.throw_completion<SyntaxError>(ErrorType::InvalidOrAmbiguousExportEntry, entry.export_name); // c. Assert: resolution is a ResolvedBinding Record. VERIFY(resolution.is_valid()); @@ -357,7 +357,7 @@ ThrowCompletionOr<void> SourceTextModule::initialize_environment(VM& vm) // ii. If resolution is null or ambiguous, throw a SyntaxError exception. if (!resolution.is_valid()) - return vm.throw_completion<SyntaxError>(global_object, ErrorType::InvalidOrAmbiguousExportEntry, import_entry.import_name); + return vm.throw_completion<SyntaxError>(ErrorType::InvalidOrAmbiguousExportEntry, import_entry.import_name); // iii. If resolution.[[BindingName]] is namespace, then if (resolution.is_namespace()) { |