ecma262
ecma262 copied to clipboard
Generator.prototype is not defined
The "Generator Objects" section first mentions "A Generator is an instance of a generator function ...".
https://tc39.es/ecma262/#sec-generator-objects
A Generator is an instance of a generator function and conforms to both the Iterator and Iterable interfaces.
Then "Properties of the Generator Prototype Object" section defines "Generator prototype object" as %GeneratorFunction.prototype.prototype%
https://tc39.es/ecma262/#sec-properties-of-generator-prototype
The Generator prototype object:
- is %GeneratorFunction.prototype.prototype%.
The "Generator prototype object" name is used by GeneratorFunction.prototype.prototype
's definition, which makes sense:
https://tc39.es/ecma262/#sec-generatorfunction.prototype.prototype
The initial value of GeneratorFunction.prototype.prototype is the Generator prototype object.
But remaining subsections of "Generator Objects" define properties of Generator.prototype
, that sounds like the same thing as %GeneratorFunction.prototype.prototype%
, but it's not defined explicitly:
https://tc39.es/ecma262/#sec-generator.prototype.constructor
27.5.1.1 Generator.prototype.constructor
https://tc39.es/ecma262/#sec-generator.prototype.next
27.5.1.2 Generator.prototype.next ( value )
It also makes the first paragraph "A Generator is an instance of ..." confusing, that it sounds like Generator
in Generator.prototype.constructor
is "A Generator" instance (which is not true, because the instance doesn't have prototype
property).
There would be 2 options to solve this:
- (A) Replace all occurrences of
Generator.prototype
with%GeneratorFunction.prototype.prototype%
(while keeping the ids of those sections, to avoid breaking links) - (B) Add a section or a paragraph that defines that
Generator.prototype
is a shorthand notation for%GeneratorFunction.prototype.prototype%
(also clarifiesGenerator
there isn't "A Generator" above)
Same for AsyncGenerator.prototype
in https://tc39.es/ecma262/#sec-asyncgenerator-objects