Skip to content

refactor(parser): refactor parse member expression#10880

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-08-refactor_parser_refactor_parse_member_expression
May 8, 2025
Merged

refactor(parser): refactor parse member expression#10880
graphite-app[bot] merged 1 commit intomainfrom
05-08-refactor_parser_refactor_parse_member_expression

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 8, 2025

closes #10615

Copilot AI review requested due to automatic review settings May 8, 2025 05:48
Copy link
Member Author

Boshen commented May 8, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels May 8, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how member expressions are parsed, adding improved handling for optional chains and decorators. Key changes include:

  • Adding a decorator check in optional chaining that triggers a clear error message.
  • Refactoring the parse_member_expression_rest function to accept an additional allow_optional_chain parameter.
  • Adjusting the call paths for static, computed, and tagged template expressions alongside enhanced error handling.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

File Description
crates/oxc_parser/src/js/expression.rs Updates to member expression parsing logic to better support decorators and optional chain syntax
crates/oxc_parser/src/diagnostics.rs New diagnostic functions for decorator usage and invalid optional chains
Comments suppressed due to low confidence (3)

crates/oxc_parser/src/js/expression.rs:872

  • [nitpick] Verify that the error produced for an optional chain in a new expression (using diagnostics::invalid_new_optional_chain) is consistent with project conventions and accurately reflects the parsing rules.
if self.at(Kind::QuestionDot) {

crates/oxc_parser/src/js/expression.rs:658

  • Double-check that the decorator check here correctly captures all cases where an expression used as a decorator should be parenthesized. Ensure that this error diagnostic aligns with similar parser error handling in related contexts.
if self.ctx.has_decorator() {

crates/oxc_parser/src/js/expression.rs:797

  • Review the control flow change introduced by the explicit return within parse_member_expression_rest to ensure it correctly exits the loop as intended without bypassing additional parsing steps.
return lhs;

@graphite-app
Copy link
Contributor

graphite-app bot commented May 8, 2025

Merge activity

@codspeed-hq
Copy link

codspeed-hq bot commented May 8, 2025

CodSpeed Instrumentation Performance Report

Merging #10880 will not alter performance

Comparing 05-08-refactor_parser_refactor_parse_member_expression (d5cd29d) with main (2c09243)

Summary

✅ 36 untouched benchmarks

@graphite-app graphite-app bot force-pushed the 05-08-refactor_parser_refactor_parse_member_expression branch from c2d0971 to d5cd29d Compare May 8, 2025 05:56
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 8, 2025
@graphite-app graphite-app bot merged commit d5cd29d into main May 8, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 05-08-refactor_parser_refactor_parse_member_expression branch May 8, 2025 06:02
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser: Should parse @x?.["y"] class C {}?

2 participants