diff --git a/js/parse.go b/js/parse.go index 46f43e4..18a3c38 100644 --- a/js/parse.go +++ b/js/parse.go @@ -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 { diff --git a/js/parse_test.go b/js/parse_test.go index 0343a87..0d91637 100644 --- a/js/parse_test.go +++ b/js/parse_test.go @@ -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))"},