Browse Source

LibJS: Assert Proxy target is a function in [[Call]] and [[Construct]]

As the TODOs suggested for a long time. :^)
Linus Groh 2 years ago
parent
commit
455537d31d
1 changed files with 2 additions and 9 deletions
  1. 2 9
      Userland/Libraries/LibJS/Runtime/ProxyObject.cpp

+ 2 - 9
Userland/Libraries/LibJS/Runtime/ProxyObject.cpp

@@ -746,11 +746,7 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV
     auto& realm = *vm.current_realm();
     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.
     // 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<TypeError>(ErrorType::NotAFunction, Value(this).to_string_without_side_effects());
+    VERIFY(is_function());
 
 
     // 1. Let handler be O.[[ProxyHandler]].
     // 1. Let handler be O.[[ProxyHandler]].
 
 
@@ -794,10 +790,7 @@ ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedVector<Value> a
     auto& realm = *vm.current_realm();
     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.
     // 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<TypeError>(ErrorType::NotAConstructor, Value(this).to_string_without_side_effects());
+    VERIFY(is_function());
 
 
     // 1. Let handler be O.[[ProxyHandler]].
     // 1. Let handler be O.[[ProxyHandler]].