Skip to content

Commit

Permalink
perf(parser): check . before [ in parse_member_expression_rest (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 28, 2024
1 parent da199c7 commit fa9a4ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/oxc_parser/src/js/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit fa9a4ec

Please sign in to comment.