From 455537d31d87146d9a4da77b6e9ebf00b566db0b Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 2 Sep 2022 22:44:44 +0100 Subject: [PATCH] LibJS: Assert Proxy target is a function in [[Call]] and [[Construct]] As the TODOs suggested for a long time. :^) --- Userland/Libraries/LibJS/Runtime/ProxyObject.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index eef9c96ba4..0769300ed9 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -746,11 +746,7 @@ ThrowCompletionOr ProxyObject::internal_call(Value this_argument, MarkedV auto& realm = *vm.current_realm(); // A Proxy exotic object only has a [[Call]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Call]] internal method. - // TODO: We should be able to turn this into a VERIFY(), this must be checked at the call site. - // 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(ErrorType::NotAFunction, Value(this).to_string_without_side_effects()); + VERIFY(is_function()); // 1. Let handler be O.[[ProxyHandler]]. @@ -794,10 +790,7 @@ ThrowCompletionOr ProxyObject::internal_construct(MarkedVector a auto& realm = *vm.current_realm(); // A Proxy exotic object only has a [[Construct]] internal method if the initial value of its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method. - // 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(ErrorType::NotAConstructor, Value(this).to_string_without_side_effects()); + VERIFY(is_function()); // 1. Let handler be O.[[ProxyHandler]].