fix(parser): fix parsing repeated static in class field#11010
Closed
magic-akari wants to merge 4 commits intooxc-project:mainfrom
Closed
fix(parser): fix parsing repeated static in class field#11010magic-akari wants to merge 4 commits intooxc-project:mainfrom
magic-akari wants to merge 4 commits intooxc-project:mainfrom
Conversation
Contributor
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
cab08c3 to
b17faf0
Compare
CodSpeed Instrumentation Performance ReportMerging #11010 will not alter performanceComparing Summary
|
e4c6657 to
dd4a747
Compare
b00c89e to
250e07e
Compare
09d78e0 to
9fffc48
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the parser behavior to correctly terminate modifier parsing at a newline, preventing duplicate recognition of the static keyword. Key changes include:
- Updating the static keyword check in the parser.
- Adjusting tests in both the minifier and codegen integration tests to reflect the new behavior.
- Commenting out an incorrect test case in the minifier tests.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_parser/src/js/class.rs | Updated the condition to avoid processing duplicate static keywords. |
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Commented out a test case for duplicated static keywords with an explanatory note. |
| crates/oxc_codegen/tests/integration/unit.rs | Added a test case to verify the new parsing logic with multiple static keywords. |
| crates/oxc_codegen/tests/integration/ts.rs | Introduced a similar test case for TypeScript integration to confirm consistent behavior. |
Comments suppressed due to low confidence (1)
crates/oxc_parser/src/js/class.rs:212
- The updated condition prevents processing a duplicate 'static' keyword by verifying that r#static is not already set, which fixes the unintended parsing behavior. Please confirm that this logic properly aligns with the intended parsing rules for class elements.
if !r#static && self.at(Kind::Static) {
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
staticin class field #10942This is a syntax error and should not parse.