ariya/esprima — pull request #205 by mroch (2013-11-16 01:27:31+00:00)
Title: Fix arrow functions in group expressions

These failed to parse:

(x) => ((y, z) => (x, y, z)) // Error: Line 1: Unexpected token =>
(x => x) // Error: Line 1: Unexpected token )

The main problem was that `parseGroupExpression` inverts `state.allowArrowFunction`, which leads to some very weird behavior.

This causes the first example above to fail because the inner arrow function isn't allowed. However, if you use two grouping operators, you get a different result!

(x) => (((y, z) => (x, y, z))) // Error: Line 1: Unexpected token )

Now this is the same bug as the second example above. The inner arrow function gets consumed by `parseGroupExpression`, but since it is an `ArrowFunctionExpression`, the trailing `)` isn't consumed and then fails in `consumeSemicolon`.

The fix for this is to move the arrow function handling from `parseGroupExpression` to `parseExpression`. Now `(x, y) => {}` gets parsed by `parseGroupExpression` as a `SequenceExpression` and then reinterpreted as a CoveredFormalsList in `parseExpression`.

https://code.google.com/p/esprima/issues/detail?id=453