Skip to content

Commit

Permalink
JS: fix parsing of 'async(...a)' as a CallExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Nov 23, 2023
1 parent 687d71b commit 66aef60
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ func (p *Parser) parseParenthesizedExpressionOrArrowFunc(prec OpPrec, async []by
left = p.scope.Use(async)
left = &CallExpr{left, Args{}, false}
precLeft = OpCall
} else if len(list) == 0 || !isAsync && rest != nil || isAsync && OpCall < prec {
} else if len(list) == 0 && rest == nil || !isAsync && rest != nil || isAsync && OpCall < prec {
p.fail("arrow function", ArrowToken)
return nil
} else {
Expand Down
1 change: 1 addition & 0 deletions js/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func TestParse(t *testing.T) {
{"async function a(){ for await (var a of b) {} }", "Decl(async function a Params() Stmt({ Stmt(for await Decl(var Binding(a)) of b Stmt({ })) }))"},
{"async function a(){ (await a) }", "Decl(async function a Params() Stmt({ Stmt((await a)) }))"},
{"x = {async a(b){}}", "Stmt(x={Method(async a Params(Binding(b)) Stmt({ }))})"},
{"async(...a)", "Stmt(async(...a))"},

// bindings
{"let [] = z", "Decl(let Binding([ ] = z))"},
Expand Down

0 comments on commit 66aef60

Please sign in to comment.