Skip to content

Commit 078e2cc

Browse files
JLHwungvedantroy
authored andcommitted
fix: check potentialArrowAt in maybeAsyncArrow
Co-Authored-By: Vedant Roy <[email protected]>
1 parent 020d8ea commit 078e2cc

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

acorn/src/expression.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ pp.parseExprSubscripts = function(refDestructuringErrors) {
262262

263263
pp.parseSubscripts = function(base, startPos, startLoc, noCalls) {
264264
let maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
265-
this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"
265+
this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
266+
this.potentialArrowAt === base.start
266267
while (true) {
267268
let element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow)
268269
if (element === base || element.type === "ArrowFunctionExpression") return element

test/tests-asyncawait.js

+2
Original file line numberDiff line numberDiff line change
@@ -3525,3 +3525,5 @@ test("({ async delete() {} })", {}, {ecmaVersion: 8})
35253525
testFail("abc: async function a() {}", "Unexpected token (1:5)", {ecmaVersion: 8})
35263526

35273527
test("(async() => { await 4 ** 2 })()", {}, {ecmaVersion: 8})
3528+
3529+
testFail("4 + async() => 2", "Unexpected token (1:12)", {ecmaVersion: 8, loose: false})

0 commit comments

Comments
 (0)