Kaynağa Gözat

LibJS: Fix "prototype" property of generator functions, again

The change in 3ec0183 wasn't actually correct, the spec tells us to set
the "prototype" property of the function (created with a prototype of
%GeneratorFunction.prototype% itself) to a newly created object:
OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%)
Linus Groh 3 yıl önce
ebeveyn
işleme
09e263dd9c

+ 1 - 1
Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp

@@ -120,7 +120,7 @@ void ECMAScriptFunctionObject::initialize(GlobalObject& global_object)
             break;
             break;
         case FunctionKind::Generator:
         case FunctionKind::Generator:
             // prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
             // prototype is "g1.prototype" in figure-2 (https://tc39.es/ecma262/img/figure-2.png)
-            prototype = global_object.generator_prototype();
+            prototype = Object::create(global_object, global_object.generator_function_prototype_prototype());
             break;
             break;
         case FunctionKind::Async:
         case FunctionKind::Async:
             break;
             break;