From fa9a4ecd4ae0ada26a7cd63bf407d7e5c0efa02c Mon Sep 17 00:00:00 2001 From: Boshen <1430279+Boshen@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:00:28 +0000 Subject: [PATCH] perf(parser): check `.` before `[` in `parse_member_expression_rest` (#6979) --- crates/oxc_parser/src/js/expression.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index aca97d9886a59..8aee5438c6551 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -635,12 +635,6 @@ impl<'a> ParserImpl<'a> { let mut lhs = lhs; loop { lhs = match self.cur_kind() { - // computed member expression is not allowed in decorator - // class C { @dec ["1"]() { } } - // ^ - Kind::LBrack if !self.ctx.has_decorator() => { - self.parse_computed_member_expression(lhs_span, lhs, false)? - } Kind::Dot => self.parse_static_member_expression(lhs_span, lhs, false)?, Kind::QuestionDot => { *in_optional_chain = true; @@ -658,6 +652,12 @@ impl<'a> ParserImpl<'a> { _ => break, } } + // computed member expression is not allowed in decorator + // class C { @dec ["1"]() { } } + // ^ + Kind::LBrack if !self.ctx.has_decorator() => { + self.parse_computed_member_expression(lhs_span, lhs, false)? + } Kind::Bang if !self.cur_token().is_on_new_line && self.is_ts => { self.bump_any(); self.ast.expression_ts_non_null(self.end_span(lhs_span), lhs)