mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-29 19:10:26 +00:00
LibJS: Use the correct prototype for generator functions
This commit is contained in:
parent
f65d25682c
commit
3ec0183b51
Notes:
sideshowbarker
2024-07-18 01:14:51 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/3ec0183b517 Pull-request: https://github.com/SerenityOS/serenity/pull/10864 Reviewed-by: https://github.com/linusg
1 changed files with 3 additions and 2 deletions
|
@ -93,14 +93,15 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
|
|||
MUST(define_property_or_throw(vm.names.name, { .value = js_string(vm, m_name.is_null() ? "" : m_name), .writable = false, .enumerable = false, .configurable = true }));
|
||||
|
||||
if (!m_is_arrow_function) {
|
||||
auto* prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
|
||||
Object* prototype = nullptr;
|
||||
switch (m_kind) {
|
||||
case FunctionKind::Regular:
|
||||
prototype = vm.heap().allocate<Object>(global_object, *global_object.new_ordinary_function_prototype_object_shape());
|
||||
MUST(prototype->define_property_or_throw(vm.names.constructor, { .value = this, .writable = true, .enumerable = false, .configurable = true }));
|
||||
break;
|
||||
case FunctionKind::Generator:
|
||||
// prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
|
||||
set_prototype(global_object.generator_object_prototype());
|
||||
prototype = global_object.generator_object_prototype();
|
||||
break;
|
||||
case FunctionKind::Async:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue