Skip to content

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented May 22, 2025

Part of #11194

NOTE: In TypeScript parser.ts, next_token_can_follow_modifier seems to be the only place to handle these checks.

https://github.com/microsoft/TypeScript/blob/b504a1eed45e35b5f54694a1e0a09f35d0a5663c/src/compiler/parser.ts#L2765

But we have two places, may revisit it later.

Copilot AI review requested due to automatic review settings May 22, 2025 05:38
@graphite-app
Copy link
Contributor

graphite-app bot commented May 22, 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-cleanup Category - technical debt or refactoring. Solution not expected to change behavior labels May 22, 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

Refactors the parser’s modifier lookahead logic by replacing non-destructive peek calls with direct token consumption and checks.

  • Replaces peek_kind() == Kind::Enum with bump_any() followed by at(Kind::Enum)
  • Replaces peek_at(Kind::Enum) with bump_any() followed by at(Kind::Enum)
Comments suppressed due to low confidence (2)

crates/oxc_parser/src/modifiers.rs:321

  • Calling bump_any() in a lookahead predicate mutates parser state unexpectedly. Consider using peek_at(Kind::Enum) or snapshotting/restoring parser position to avoid side-effects.
Kind::Const => { self.bump_any(); self.at(Kind::Enum) },

crates/oxc_parser/src/modifiers.rs:457

  • This replacement also consumes the Const token during a lookahead. To preserve parser state, revert to a non-destructive peek or implement position rewind after consuming.
Kind::Const => { self.bump_any(); self.at(Kind::Enum) },

@codspeed-hq
Copy link

codspeed-hq bot commented May 22, 2025

CodSpeed Instrumentation Performance Report

Merging #11228 will not alter performance

Comparing r/remove-peek-modifiers (07e6ae0) with main (62f7184)

Summary

✅ 38 untouched benchmarks

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label May 22, 2025
Copy link
Member

Boshen commented May 22, 2025

Merge activity

Part of #11194

NOTE: In TypeScript parser.ts, `next_token_can_follow_modifier` seems to be the only place to handle these checks.

https://github.com/microsoft/TypeScript/blob/b504a1eed45e35b5f54694a1e0a09f35d0a5663c/src/compiler/parser.ts#L2765

But we have two places, may revisit it later.
@graphite-app graphite-app bot force-pushed the r/remove-peek-modifiers branch from a91ca36 to 07e6ae0 Compare May 22, 2025 06:06
@graphite-app graphite-app bot merged commit 07e6ae0 into main May 22, 2025
25 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label May 22, 2025
@graphite-app graphite-app bot deleted the r/remove-peek-modifiers branch May 22, 2025 06:13
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.

3 participants