summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/Value.cpp
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-06-10 23:50:48 +0300
committerLinus Groh <mail@linusgroh.de>2021-06-10 22:44:26 +0100
commitb041108a1e4afc72905be9b60285890ddf41ad48 (patch)
tree886a481e1b9b744a89ed05a445817700709e453f /Userland/Libraries/LibJS/Runtime/Value.cpp
parent4531f689ff2fa976ffcbfadd329a1b3c903c00af (diff)
downloadserenity-b041108a1e4afc72905be9b60285890ddf41ad48.zip
LibJS: Explicitly return and accept a Function* in species_constructor
The second argument (the default constructor) and the return value have to be constructors (as a result functions), so we can require that explicitly by using appropriate types.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Value.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index df4429f66f..ded9689eaf 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -1387,7 +1387,7 @@ size_t length_of_array_like(GlobalObject& global_object, const Object& object)
}
// 7.3.22 SpeciesConstructor, https://tc39.es/ecma262/#sec-speciesconstructor
-Object* species_constructor(GlobalObject& global_object, const Object& object, Object& default_constructor)
+Function* species_constructor(GlobalObject& global_object, const Object& object, Function& default_constructor)
{
auto& vm = global_object.vm();
auto constructor = object.get(vm.names.constructor).value_or(js_undefined());
@@ -1403,7 +1403,7 @@ Object* species_constructor(GlobalObject& global_object, const Object& object, O
if (species.is_nullish())
return &default_constructor;
if (species.is_constructor())
- return &species.as_object();
+ return &species.as_function();
vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, species.to_string_without_side_effects());
return nullptr;
}