From c4ccf9f4d884db36bb621d069997e403b22420c5 Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Tue, 14 May 2024 03:18:41 +0000 Subject: [PATCH] fix(parser): parse `DecoratorCallExpression` when `Arguments` contains `MemberExpression` (#3265) closes #3261 closes #3262 ``` DecoratorCallExpression[Yield, Await] : DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] ``` --- crates/oxc_parser/src/js/expression.rs | 5 ++++- tasks/coverage/codegen_misc.snap | 4 ++-- tasks/coverage/misc/pass/oxc-3262.js | 4 ++++ tasks/coverage/parser_misc.snap | 4 ++-- tasks/coverage/prettier_misc.snap | 4 ++-- tasks/coverage/transformer_misc.snap | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 tasks/coverage/misc/pass/oxc-3262.js diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index a178f0c2e..4b506aef3 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -750,7 +750,10 @@ impl<'a> ParserImpl<'a> { ) -> Result> { // ArgumentList[Yield, Await] : // AssignmentExpression[+In, ?Yield, ?Await] - let call_arguments = self.with_context(Context::In, CallArguments::parse)?; + let ctx = self.ctx; + self.ctx = ctx.and_in(true).and_decorator(false); + let call_arguments = CallArguments::parse(self)?; + self.ctx = ctx; Ok(self.ast.call_expression( self.end_span(lhs_span), lhs, diff --git a/tasks/coverage/codegen_misc.snap b/tasks/coverage/codegen_misc.snap index 8844037bd..0c34c74b8 100644 --- a/tasks/coverage/codegen_misc.snap +++ b/tasks/coverage/codegen_misc.snap @@ -1,3 +1,3 @@ codegen_misc Summary: -AST Parsed : 15/15 (100.00%) -Positive Passed: 15/15 (100.00%) +AST Parsed : 16/16 (100.00%) +Positive Passed: 16/16 (100.00%) diff --git a/tasks/coverage/misc/pass/oxc-3262.js b/tasks/coverage/misc/pass/oxc-3262.js new file mode 100644 index 000000000..388a20d93 --- /dev/null +++ b/tasks/coverage/misc/pass/oxc-3262.js @@ -0,0 +1,4 @@ +class Foo { + @Bar({ x: Map['String'] }) + quaz() {} +} diff --git a/tasks/coverage/parser_misc.snap b/tasks/coverage/parser_misc.snap index 842ba718e..b0d7f5379 100644 --- a/tasks/coverage/parser_misc.snap +++ b/tasks/coverage/parser_misc.snap @@ -1,6 +1,6 @@ parser_misc Summary: -AST Parsed : 15/15 (100.00%) -Positive Passed: 15/15 (100.00%) +AST Parsed : 16/16 (100.00%) +Positive Passed: 16/16 (100.00%) Negative Passed: 8/8 (100.00%) × Unexpected token diff --git a/tasks/coverage/prettier_misc.snap b/tasks/coverage/prettier_misc.snap index 5406892e6..52f998d27 100644 --- a/tasks/coverage/prettier_misc.snap +++ b/tasks/coverage/prettier_misc.snap @@ -1,6 +1,6 @@ prettier_misc Summary: -AST Parsed : 15/15 (100.00%) -Positive Passed: 8/15 (53.33%) +AST Parsed : 16/16 (100.00%) +Positive Passed: 9/16 (56.25%) Expect to Parse: "pass/oxc-1740.tsx" Expect to Parse: "pass/oxc-2087.ts" Expect to Parse: "pass/oxc-2394.ts" diff --git a/tasks/coverage/transformer_misc.snap b/tasks/coverage/transformer_misc.snap index 0fda3ca94..aee9d4595 100644 --- a/tasks/coverage/transformer_misc.snap +++ b/tasks/coverage/transformer_misc.snap @@ -1,3 +1,3 @@ transformer_misc Summary: -AST Parsed : 15/15 (100.00%) -Positive Passed: 15/15 (100.00%) +AST Parsed : 16/16 (100.00%) +Positive Passed: 16/16 (100.00%)