1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:27:45 +00:00

LibJS: Fix value of Generator.prototype.constructor

The spec says:

    27.5.1.1 Generator.prototype.constructor
    https://tc39.es/ecma262/#sec-generator.prototype.constructor

    The initial value of Generator.prototype.constructor is
    %GeneratorFunction.prototype%.

But we had it set to %GeneratorFunction% (the GeneratorFunction
constructor).
This commit is contained in:
Linus Groh 2022-01-16 14:47:14 +01:00
parent 4ed49e05a9
commit 30af8121ce

View file

@ -169,7 +169,6 @@ void GlobalObject::initialize_global_object()
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
// companion constructor
m_generator_prototype = heap().allocate<GeneratorPrototype>(*this, *this);
m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
m_async_from_sync_iterator_prototype = heap().allocate<AsyncFromSyncIteratorPrototype>(*this, *this);
@ -288,6 +287,9 @@ void GlobalObject::initialize_global_object()
// 27.4.3.1 AsyncGeneratorFunction.prototype.constructor, https://tc39.es/ecma262/#sec-asyncgeneratorfunction-prototype-constructor
m_async_generator_function_prototype->define_direct_property(vm.names.constructor, m_async_generator_function_constructor, Attribute::Configurable);
// 27.5.1.1 Generator.prototype.constructor, https://tc39.es/ecma262/#sec-generator.prototype.constructor
m_generator_prototype->define_direct_property(vm.names.constructor, m_generator_function_prototype, Attribute::Configurable);
m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
m_date_constructor_now_function = &m_date_constructor->get_without_side_effects(vm.names.now).as_function();
m_eval_function = &get_without_side_effects(vm.names.eval).as_function();