From e37f96ccfef72bc36b5a726a045c061757074ad1 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Thu, 1 Jul 2021 02:18:49 +0300 Subject: [PATCH] LibJS: Stop coercing this to object in Function's Symbol.hasInstance --- Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp index 34ef045af0..3c62678e04 100644 --- a/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/FunctionPrototype.cpp @@ -162,14 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::to_string) // 20.2.3.6 Function.prototype [ @@hasInstance ] ( V ), https://tc39.es/ecma262/#sec-function.prototype-@@hasinstance JS_DEFINE_NATIVE_FUNCTION(FunctionPrototype::symbol_has_instance) { - auto* this_object = vm.this_value(global_object).to_object(global_object); - if (!this_object) - return {}; - if (!this_object->is_function()) { - vm.throw_exception(global_object, ErrorType::NotA, "Function"); - return {}; - } - return ordinary_has_instance(global_object, vm.argument(0), this_object); + return ordinary_has_instance(global_object, vm.argument(0), vm.this_value(global_object)); } }