From efbd8ee07226a70aab348bdfcfa6d1bbb5e3ab5c Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Tue, 13 Dec 2022 20:49:50 +0000 Subject: [PATCH] LibJS: Convert BoundFunction::create() to NonnullGCPtr --- Userland/Libraries/LibJS/Runtime/BoundFunction.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/BoundFunction.h | 2 +- Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp index 8b317fba904..e2871b05a10 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.cpp @@ -12,7 +12,7 @@ namespace JS { // 10.4.1.3 BoundFunctionCreate ( targetFunction, boundThis, boundArgs ), https://tc39.es/ecma262/#sec-boundfunctioncreate -ThrowCompletionOr BoundFunction::create(Realm& realm, FunctionObject& target_function, Value bound_this, Vector bound_arguments) +ThrowCompletionOr> BoundFunction::create(Realm& realm, FunctionObject& target_function, Value bound_this, Vector bound_arguments) { // 1. Let proto be ? targetFunction.[[GetPrototypeOf]](). auto* prototype = TRY(target_function.internal_get_prototype_of()); @@ -29,7 +29,7 @@ ThrowCompletionOr BoundFunction::create(Realm& realm, FunctionOb auto* object = realm.heap().allocate(realm, realm, target_function, bound_this, move(bound_arguments), prototype); // 10. Return obj. - return object; + return NonnullGCPtr { *object }; } BoundFunction::BoundFunction(Realm& realm, FunctionObject& bound_target_function, Value bound_this, Vector bound_arguments, Object* prototype) diff --git a/Userland/Libraries/LibJS/Runtime/BoundFunction.h b/Userland/Libraries/LibJS/Runtime/BoundFunction.h index a5e11c64987..72603cf8cb7 100644 --- a/Userland/Libraries/LibJS/Runtime/BoundFunction.h +++ b/Userland/Libraries/LibJS/Runtime/BoundFunction.h @@ -15,7 +15,7 @@ class BoundFunction final : public FunctionObject { JS_OBJECT(BoundFunction, FunctionObject); public: - static ThrowCompletionOr create(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments); + static ThrowCompletionOr> create(Realm&, FunctionObject& target_function, Value bound_this, Vector bound_arguments); virtual ~BoundFunction() override = default; diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index bb2f1f50131..fc5329f8f9a 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::bind) } // 3. Let F be ? BoundFunctionCreate(Target, thisArg, args). - auto* function = TRY(BoundFunction::create(realm, target, this_argument, move(arguments))); + auto function = TRY(BoundFunction::create(realm, target, this_argument, move(arguments))); // 4. Let argCount be the number of elements in args. auto arg_count = vm.argument_count() > 0 ? vm.argument_count() - 1 : 0;