Skip to content

fix(parser): guard against re-lex tokens when fatal error#11023

Merged
graphite-app[bot] merged 1 commit intomainfrom
05-14-fix_parser_guard_against_re-lex_tokens_when_fatal_error
May 14, 2025
Merged

fix(parser): guard against re-lex tokens when fatal error#11023
graphite-app[bot] merged 1 commit intomainfrom
05-14-fix_parser_guard_against_re-lex_tokens_when_fatal_error

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented May 14, 2025

fixes #10977

Copilot AI review requested due to automatic review settings May 14, 2025 05:29
@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels May 14, 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 fixes an issue in the parser by ensuring that token re-lexing does not occur once a fatal error has been encountered and by removing a redundant call in type argument parsing.

  • Remove duplicate call to re-lex the left angle token in type argument parsing
  • Add guards in the cursor re-lex functions to return EOF if a fatal error is present

Reviewed Changes

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

File Description
crates/oxc_parser/src/ts/types.rs Removed a redundant re-lex call to prevent side effects in type argument parsing
crates/oxc_parser/src/cursor.rs Added fatal error guards in re-lex functions to avoid token re-lexing after errors
Comments suppressed due to low confidence (1)

crates/oxc_parser/src/ts/types.rs:790

  • Consider caching the result of self.re_lex_l_angle() in a local variable to ensure consistent behavior, avoiding unexpected side effects if the re-lexing function modifies internal state.
if !self.cur_token().is_on_new_line() && self.re_lex_l_angle() == Kind::LAngle {

Copy link
Member Author

Boshen commented May 14, 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.

@graphite-app
Copy link
Contributor

graphite-app bot commented May 14, 2025

Merge activity

@codspeed-hq
Copy link

codspeed-hq bot commented May 14, 2025

CodSpeed Instrumentation Performance Report

Merging #11023 will not alter performance

Comparing 05-14-fix_parser_guard_against_re-lex_tokens_when_fatal_error (4c9a9b3) with main (2b02d84)

Summary

✅ 36 untouched benchmarks

@graphite-app graphite-app bot force-pushed the 05-14-fix_parser_guard_against_re-lex_tokens_when_fatal_error branch from c3789dc to 4c9a9b3 Compare May 14, 2025 05:37
@graphite-app graphite-app bot merged commit 4c9a9b3 into main May 14, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 05-14-fix_parser_guard_against_re-lex_tokens_when_fatal_error branch May 14, 2025 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic Offset is not on a UTF-8 character boundary in crates/oxc_parser/src/lexer/source.rs

2 participants