From 66aef60153a7efca24949f32c46c4374b4a4dec6 Mon Sep 17 00:00:00 2001 From: Taco de Wolff Date: Thu, 23 Nov 2023 17:27:13 -0300 Subject: [PATCH] JS: fix parsing of 'async(...a)' as a CallExpression --- js/parse.go | 2 +- js/parse_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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))"},