diff --git a/src/expression.js b/src/expression.js index 3ab754733d..cc5667f815 100755 --- a/src/expression.js +++ b/src/expression.js @@ -292,7 +292,7 @@ pp.parseExprAtom = function(refShorthandDefaultPos) { // if (this.options.features["es7.asyncFunctions"]) { // async functions! - if (id.name === "async") { + if (id.name === "async" && !this.canInsertSemicolon()) { // arrow functions if (this.type === tt.parenL) { let expr = this.parseParenAndDistinguishExpression(start, true, true) diff --git a/src/lookahead.js b/src/lookahead.js index faedbd8d2a..9faecdbf04 100644 --- a/src/lookahead.js +++ b/src/lookahead.js @@ -9,6 +9,7 @@ var STATE_KEYS = [ "lastTokEnd", "lineStart", "startLoc", + "curLine", "endLoc", "start", "pos", diff --git a/src/statement.js b/src/statement.js index 17a17b0b79..140f349a16 100755 --- a/src/statement.js +++ b/src/statement.js @@ -83,10 +83,13 @@ pp.parseStatement = function(declaration, topLevel) { return starttype === tt._import ? this.parseImport(node) : this.parseExport(node) case tt.name: - if (this.options.features["es7.asyncFunctions"] && this.value === "async" && this.lookahead().type === tt._function) { - this.next(); - this.expect(tt._function); - return this.parseFunction(node, true, false, true); + if (this.options.features["es7.asyncFunctions"] && this.value === "async") { + var lookahead = this.lookahead(); + if (lookahead.type === tt._function && !this.canInsertSemicolon.call(lookahead)) { + this.next(); + this.expect(tt._function); + return this.parseFunction(node, true, false, true); + } } // If the statement does not start with a statement keyword or a