fix parser bug where arrow functions have a higher precedence than they should - fixes #2118

This commit is contained in:
Sebastian McKenzie
2015-10-30 22:50:53 +00:00
parent 37159fbc7d
commit 7012116f4e
13 changed files with 119 additions and 8 deletions

View File

@@ -128,7 +128,8 @@ pp.parseStatement = function (declaration, topLevel) {
// simply start parsing an expression, and afterwards, if the
// next token is a colon and the expression was a simple
// Identifier node, we switch to interpreting it as a label.
let maybeName = this.state.value, expr = this.parseExpression();
let maybeName = this.state.value;
let expr = this.parseExpression();
if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) {
return this.parseLabeledStatement(node, maybeName, expr);