Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upShould arrow functions allow `yield` as identifier name in StrictFormalParameters? #397
Comments
ianwjhalliday
referenced this issue
Feb 18, 2016
Closed
yield should be reserved word in arrow functions within StrictFormalParameters #333
bterlson
added
the
question
label
Feb 18, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
michaelficarra
Feb 22, 2016
Member
Currently, 14.2.1 defines an early error that disallows _YieldExpression_s in ArrowParameters.
It is a Syntax Error if ArrowParameters Contains YieldExpression is true.
So the only difference this grammar change would make would be allowing yield used as an identifier in ArrowParameters (or conversely disallowing yield used as an identifier in FormalParameters, but that would be web incompatible).
|
Currently, 14.2.1 defines an early error that disallows _YieldExpression_s in ArrowParameters.
So the only difference this grammar change would make would be allowing |
michaelficarra
referenced this issue
Feb 22, 2016
Closed
`yield` flag is passed to arrow bodies #270
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Feb 22, 2016
Contributor
Even when [Yield] gets removed, yield still cannot be used as the name of an arrow function default parameter in a generator function context.
function* g() {
// Default parameters cannot be named "yield", because `yield = 0`
// is initially parsed as an assignment expression.
var f = (yield = 0) => {};
}And removing [Yield] probably also complicates correctly reinterpreting CoverParenthesizedExpressionAndArrowParameterList as ArrowFormalParameters:
function* g() {
// Lexical token sequence for `yield/a/i` is `YIELD REGEXP`.
// When CoverParenthesizedExpressionAndArrowParameterList is reinterpreted/reparsed
// as ArrowFormalParameters, the lexer/parser is not allowed to change this to the
// token sequence `YIELD DIV IDENT DIV IDENT`.
var f = (p = yield/a/i) => {};
}|
Even when [Yield] gets removed, function* g() {
// Default parameters cannot be named "yield", because `yield = 0`
// is initially parsed as an assignment expression.
var f = (yield = 0) => {};
}And removing [Yield] probably also complicates correctly reinterpreting CoverParenthesizedExpressionAndArrowParameterList as ArrowFormalParameters: function* g() {
// Lexical token sequence for `yield/a/i` is `YIELD REGEXP`.
// When CoverParenthesizedExpressionAndArrowParameterList is reinterpreted/reparsed
// as ArrowFormalParameters, the lexer/parser is not allowed to change this to the
// token sequence `YIELD DIV IDENT DIV IDENT`.
var f = (p = yield/a/i) => {};
} |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ianwjhalliday
Feb 23, 2016
@anba ah, there's the gotcha with arrow functions! Thanks for pointing that out. I see the need for the asymmetry now.
ianwjhalliday
commented
Feb 23, 2016
|
@anba ah, there's the gotcha with arrow functions! Thanks for pointing that out. I see the need for the asymmetry now. |
ianwjhalliday commentedFeb 18, 2016
Currently arrow functions pass along the Yield parameter to their parameter list grammar production, making yield a reserved word in that context.
However, function expressions do not pass the Yield parameter along to their FormalParameters production.
Corner case but seems an odd asymmetry.