Skip to content

Commit

Permalink
fix: check potentialArrowAt in maybeAsyncArrow
Browse files Browse the repository at this point in the history
Co-Authored-By: Vedant Roy <vroy101@gmail.com>
  • Loading branch information
2 people authored and marijnh committed Mar 20, 2020
1 parent 020d8ea commit 078e2cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ pp.parseExprSubscripts = function(refDestructuringErrors) {

pp.parseSubscripts = function(base, startPos, startLoc, noCalls) {
let maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"
this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
this.potentialArrowAt === base.start
while (true) {
let element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow)
if (element === base || element.type === "ArrowFunctionExpression") return element
Expand Down
2 changes: 2 additions & 0 deletions test/tests-asyncawait.js
Original file line number Diff line number Diff line change
Expand Up @@ -3525,3 +3525,5 @@ test("({ async delete() {} })", {}, {ecmaVersion: 8})
testFail("abc: async function a() {}", "Unexpected token (1:5)", {ecmaVersion: 8})

test("(async() => { await 4 ** 2 })()", {}, {ecmaVersion: 8})

testFail("4 + async() => 2", "Unexpected token (1:12)", {ecmaVersion: 8, loose: false})

0 comments on commit 078e2cc

Please sign in to comment.