From 78895984e9b703cc00e0a9aeb55d39c5e0f2f060 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 10 Dec 2022 00:11:42 +0000 Subject: [PATCH] LibJS: Add spec comments to Value::invoke_internal() --- Userland/Libraries/LibJS/Runtime/Value.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index e532addb75..c69ccd4325 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -2455,11 +2455,13 @@ ThrowCompletionOr is_less_than(VM& vm, Value lhs, Value rhs, bool left // 7.3.21 Invoke ( V, P [ , argumentsList ] ), https://tc39.es/ecma262/#sec-invoke ThrowCompletionOr Value::invoke_internal(VM& vm, PropertyKey const& property_key, Optional> arguments) { - auto property = TRY(get(vm, property_key)); - if (!property.is_function()) - return vm.throw_completion(ErrorType::NotAFunction, property.to_string_without_side_effects()); + // 1. If argumentsList is not present, set argumentsList to a new empty List. - return call(vm, property.as_function(), *this, move(arguments)); + // 2. Let func be ? GetV(V, P). + auto function = TRY(get(vm, property_key)); + + // 3. Return ? Call(func, V, argumentsList). + return call(vm, function, *this, move(arguments)); } }