Skip to content

fix(parser): reset popped lexer errors when rewinding#13494

Merged
Boshen merged 2 commits intooxc-project:mainfrom
ulrichstark:even-reset-popped-lexer-errors-when-rewinding
Sep 1, 2025
Merged

fix(parser): reset popped lexer errors when rewinding#13494
Boshen merged 2 commits intooxc-project:mainfrom
ulrichstark:even-reset-popped-lexer-errors-when-rewinding

Conversation

@ulrichstark
Copy link
Contributor

Closes #12816.
Alternative to #13460.

This PR is the slightly cleaner way to fix the issue compared to the other PR, but comes at a potential performance cost because now instead of remembering how many errors there were, we are storing a clone of all errors and re-assign them when rewinding.

This makes it possible to fix the issue because now even errors before a checkpoint, that were popped/removed after the checkpoint, are properly rewinded.

Copilot AI review requested due to automatic review settings August 31, 2025 18:50
@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Aug 31, 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

Fixes a lexer rewinding bug where popped errors before a checkpoint weren't properly restored when rewinding. This changes the error handling strategy from storing an error count to storing a complete clone of all errors.

  • Modifies LexerCheckpoint to store a full clone of errors instead of just the error count
  • Updates checkpoint creation and rewinding methods to use the new error cloning approach
  • Renames position field to source_position for clarity

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed Instrumentation Performance Report

Merging #13494 will not alter performance

Comparing ulrichstark:even-reset-popped-lexer-errors-when-rewinding (cdd7466) with main (dc9645f)

Summary

✅ 37 untouched benchmarks

@ulrichstark
Copy link
Contributor Author

Some parser benchmarks improved and some regressed. Interesting... This makes this solution even better.

@Boshen Boshen merged commit 65aca9e into oxc-project:main Sep 1, 2025
25 checks passed
@ulrichstark ulrichstark deleted the even-reset-popped-lexer-errors-when-rewinding branch September 1, 2025 16:58
graphite-app bot pushed a commit that referenced this pull request Sep 2, 2025
partially addresses the perf regression in #13494

Not quite as fast as originally, but a little bit faster
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 called Option::unwrap() on a None value in rules/eslint/new_cap.rs

3 participants