archives

« Bugzilla Issues Index

#2508 — 14.1 FunctionDeclaration, 14.4 GeneratorDeclaration: Disallow "yield" as BindingIdentifier in Function/GeneratorDeclaration when enclosed by generator


14.1 FunctionDeclaration and 14.4 GeneratorDeclaration both allow "yield" as the BindingIdentifier for their function names, that means this is currently allowed:
---
function outerFunction() {
function yield(){}
function* yield(){}
}
function* outerGenerator() {
function yield(){}
function* yield(){}
}
---

There is also no restriction for FunctionExpression:
---
function outerFunction() {
(function yield(){});
}
function* outerGenerator() {
(function yield(){});
}
---

GeneratorExpression does not allow "yield" as the optional BindingIdentifier:
---
function outerFunction() {
// SyntaxError: "yield" not allowd
(function* yield(){});
}
function* outerGenerator() {
// SyntaxError: "yield" not allowd
(function* yield(){});
}
---


This is not consequent, either allow "yield" as the optional BindingIdentifier in GeneratorExpression or disallow "yield" as the BindingIdentifier in Function/GeneratorDeclaration if enclosed by generator code. I think the latter choice is correct.


fixed in rev23 editor's draft


fixed in rev23 draft