Grammar question about ArrowFormalParameters

Allen Wirfs-Brock allen at
Thu Nov 13 14:24:33 PST 2014

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 and the second algorithm in  

> 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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list