Why is no line break is needed in ArrowFunction?

Waldemar Horwat waldemar at google.com
Wed Oct 21 22:28:47 UTC 2015


On 10/21/2015 00:27, Eric Suen wrote:
> Try to write a parser for es6, is this the right place for question about syntax?
>
> There is no expression or statement start with =>, same goes to yield  [no LineTerminator here] * AssignmentExpression ?

   yield [no LineTerminator here] * AssignmentExpression

has the line terminator restriction because yield without the * has the same restriction:

   yield [no LineTerminator here] AssignmentExpression

And that one has that restriction because there exists a third form of yield that doesn't take an expression:

   yield

This is the same situation as with return statements, which also take a [no LineTerminator here] restriction.  It's a convenience to prevent return from capturing the expression from the next line for the users (I'm not among them) who like to rely on semicolon insertion:

if (error) return
x = y


     Waldemar



More information about the es-discuss mailing list