Skip to content

Commit

Permalink
Revert "Add explicit exception for 'async of' not starting arrow in f…
Browse files Browse the repository at this point in the history
…or init context"

This reverts commit 7cbe0f9.
  • Loading branch information
marijnh committed May 4, 2021
1 parent 3b69e2a commit d7fc125
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
7 changes: 2 additions & 5 deletions acorn/src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,8 @@ pp.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
}

let startPos = this.start, startLoc = this.startLoc
if (this.type === tt.parenL || this.type === tt.name) {
if (this.type === tt.parenL || this.type === tt.name)
this.potentialArrowAt = this.start
this.forbidAsyncOfArrow = !!noIn
}
let left = this.parseMaybeConditional(noIn, refDestructuringErrors)
if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc)
if (this.type.isAssign) {
Expand Down Expand Up @@ -416,8 +414,7 @@ pp.parseExprAtom = function(refDestructuringErrors) {
if (canBeArrow && !this.canInsertSemicolon()) {
if (this.eat(tt.arrow))
return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false)
if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === tt.name && !containsEsc &&
(!this.forbidAsyncOfArrow || this.value !== "of" || this.containsEsc)) {
if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === tt.name && !containsEsc) {
id = this.parseIdent(false)
if (this.canInsertSemicolon() || !this.eat(tt.arrow))
this.unexpected()
Expand Down
1 change: 0 additions & 1 deletion acorn/src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class Parser {

// Used to signify the start of a potential arrow function
this.potentialArrowAt = -1
this.forbidAsyncOfArrow = false

// Positions to delayed-check that yield/await does not exist in default parameters.
this.yieldPos = this.awaitPos = this.awaitIdentPos = 0
Expand Down
2 changes: 0 additions & 2 deletions test/tests-asyncawait.js
Original file line number Diff line number Diff line change
Expand Up @@ -3522,8 +3522,6 @@ test(

test("({ async delete() {} })", {}, {ecmaVersion: 8})

test("for (async of []) {}", {}, {ecmaVersion: 8})

testFail("abc: async function a() {}", "Unexpected token (1:5)", {ecmaVersion: 8})

testFail("(async() => { await 4 ** 2 })()", "Unexpected token (1:22)", {ecmaVersion: 8})
Expand Down

0 comments on commit d7fc125

Please sign in to comment.