mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
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.
This commit is contained in:
committed by
Linus Groh
parent
4531f689ff
commit
b041108a1e
Notes:
sideshowbarker
2024-07-18 12:28:29 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/b041108a1e4 Pull-request: https://github.com/SerenityOS/serenity/pull/7974 Reviewed-by: https://github.com/linusg
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user