Skip to content

fix(parser): fix parsing repeated static in class field#11010

Closed
magic-akari wants to merge 4 commits intooxc-project:mainfrom
magic-akari:fix/issue-10942
Closed

fix(parser): fix parsing repeated static in class field#11010
magic-akari wants to merge 4 commits intooxc-project:mainfrom
magic-akari:fix/issue-10942

Conversation

@magic-akari
Copy link
Contributor

@magic-akari magic-akari commented May 13, 2025

This is a syntax error and should not parse.

class A {static static static(){}}

@graphite-app
Copy link
Contributor

graphite-app bot commented May 13, 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.

@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels May 13, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented May 13, 2025

CodSpeed Instrumentation Performance Report

Merging #11010 will not alter performance

Comparing magic-akari:fix/issue-10942 (a1f4757) with main (4c9a9b3)

Summary

✅ 36 untouched benchmarks

@github-actions github-actions bot added the A-codegen Area - Code Generation label May 13, 2025
@github-actions github-actions bot added the A-minifier Area - Minifier label May 14, 2025
@magic-akari magic-akari marked this pull request as ready for review May 14, 2025 06:16
Copilot AI review requested due to automatic review settings May 14, 2025 06:16
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 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) {

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Boshen Boshen changed the title fix(parser): Terminate modifier parsing at newline fix(parser): fix parsing repeated static in class field May 14, 2025
Boshen added a commit that referenced this pull request May 14, 2025
Boshen added a commit that referenced this pull request May 14, 2025
Boshen added a commit that referenced this pull request May 14, 2025
@graphite-app graphite-app bot closed this in 751876b May 14, 2025
@magic-akari magic-akari deleted the fix/issue-10942 branch May 14, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-codegen Area - Code Generation A-minifier Area - Minifier A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue parsing repeated static in class field

2 participants