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

As the TODOs suggested for a long time. :^)
This commit is contained in:
Linus Groh 2022-09-02 22:44:44 +01:00
parent fb5a39498a
commit 455537d31d
Notes: sideshowbarker 2024-07-17 07:33:47 +09:00

View file

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