Skip to content

Commit

Permalink
Fix mishandling of astral characters after "async function"
Browse files Browse the repository at this point in the history
Closes #1037

FIX: Fix a bug where astral characters after `async function` were ignored.
  • Loading branch information
marijnh committed May 20, 2021
1 parent f85a712 commit 164bf8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions acorn/src/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ pp.isAsyncFunction = function() {

skipWhiteSpace.lastIndex = this.pos
let skip = skipWhiteSpace.exec(this.input)
let next = this.pos + skip[0].length
let next = this.pos + skip[0].length, after
return !lineBreak.test(this.input.slice(this.pos, next)) &&
this.input.slice(next, next + 8) === "function" &&
(next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))
(next + 8 === this.input.length ||
!(isIdentifierChar(after = this.input.charCodeAt(next + 8)) || after > 0xd7ff && after < 0xdc00))
}

// Parse a single statement.
Expand Down
2 changes: 2 additions & 0 deletions test/tests-asyncawait.js
Original file line number Diff line number Diff line change
Expand Up @@ -3539,3 +3539,5 @@ test("async() => await (5 ** 6)", {}, {ecmaVersion: 8})
testFail("async() => await (5) ** 6", "Unexpected token (1:21)", {ecmaVersion: 8})

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

testFail("async function𝐬 f() {}", "Unexpected token (1:17)", {ecmaVersion: 8})

0 comments on commit 164bf8f

Please sign in to comment.