浏览代码

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).
Linus Groh 3 年之前
父节点
当前提交
30af8121ce
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      Userland/Libraries/LibJS/Runtime/GlobalObject.cpp

+ 3 - 1
Userland/Libraries/LibJS/Runtime/GlobalObject.cpp

@@ -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();