Hi Allen,
I see. This was the part that was missed:
If the [Yield] grammar parameter is present for
CoverParenthesizedExpressionAndArrowParameterList[Yield] return the result of
parsing the lexical token stream matched by
CoverParenthesizedExpressionAndArrowParameterList[Yield] using
ArrowFormalParameters[Yield, GeneratorParameter] as the goal symbol
That does clear up the grammar question.
Thanks much!
-- Cyrus
From: Allen Wirfs-Brock [mailto:[email protected]]
Sent: Thursday, November 13, 2014 2:25 PM
To: Cyrus Najmabadi
Cc: es-discuss list; Jason Freeman
Subject: Re: Grammar question about ArrowFormalParameters
On Nov 12, 2014, at 4:46 PM, Cyrus Najmabadi wrote:
Hey ES6ers,
I'm currently implementing some of the ES6 support for the next version of
TypeScript. The part I'm looking at right now is generators and yield
expressions. So far we feel fairly comfortable with the grammar and understand
the implications of the [Yield] and [GeneratorParameter]. One spec issue that
is getting us to scratch our heads though is this section:
When the production
ArrowParameters[Yield] :
CoverParenthesizedExpressionAndArrowParameterList[?Yield]
is recognized the following grammar is used to refine the interpretation of
CoverParenthesizedExpressionAndArrowParameterList:
ArrowFormalParameters[Yield, GeneratorParameter] :
( StrictFormalParameters[?Yield, ?GeneratorParameter] )
The issue relates to the [GeneratorParamater] parameter on
ArrowFormalParameters. We can't see any path through the grammar that could
ever end up enabling this parameter. While
CoverParenthesizedExpressionAndArrowParameterList picks up the 'yield'
parameter from ArrowParameters, there seems to be nothing related to
'GeneratorParameter'.
See static semantic rules of
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-arrow-function-definitions-static-semantics-early-errors
and the second algorithm in
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-semantics-coveredformalslist
We also find the presence of this grammar parameter here to be somewhat odd as
arrow function can't be generators.
It is dealing with code such as this:
var yield = 42;
function *g() {
var f = (arg=yield) => arg; //it is a syntax error to use 'yield' within
an arraw parameter list inside a generator function
yield f();
}
Is this an issue with the spec? Or is there some subtlety here that we've
missed that enables this parameter?
It's subtle.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss