Skip to content

fix(parser): parse for (using of = ...) as using declaration#18142

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/parser-using-of-for-statement
Jan 18, 2026
Merged

fix(parser): parse for (using of = ...) as using declaration#18142
graphite-app[bot] merged 1 commit intomainfrom
fix/parser-using-of-for-statement

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 17, 2026

Summary

  • Fix parsing of for (using of = null;;) as a using declaration where of is the binding identifier
  • Previously, the parser incorrectly treated of as the keyword starting a for-of loop

The fix uses a lookahead to check if the token after of is =, ;, or :, matching TypeScript's parser behavior.

Test plan

  • cargo coverage -- parser - conformance tests pass
  • cargo test -p oxc_parser - unit tests pass

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 17, 2026 17:09
@github-actions github-actions bot added A-parser Area - Parser C-bug Category - Bug labels Jan 17, 2026
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jan 17, 2026
Copy link
Member Author

Boshen commented Jan 17, 2026

Merge activity

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 a parser bug where for (using of = ...) was incorrectly treated as a for-of loop instead of a using declaration with of as the binding identifier. The fix uses a lookahead to check the token after of to distinguish between the two cases.

Changes:

  • Modified lookahead logic in for statement parsing to handle of as a binding identifier in using declarations
  • Improved test coverage with previously failing test262 and Babel test cases now passing

Reviewed changes

Copilot reviewed 1 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/oxc_parser/src/js/statement.rs Updated lookahead logic for using declarations to check tokens after of
tasks/coverage/snapshots/parser_test262.snap Improved parsing success rate with using-for-statement.js now passing
tasks/coverage/snapshots/parser_babel.snap Multiple using declaration tests now parse correctly
tasks/coverage/snapshots/parser_typescript.snap TypeScript using declaration test now parses correctly
tasks/coverage/snapshots/semantic_test262.snap Semantic analysis passes for newly parsed test
tasks/coverage/snapshots/semantic_babel.snap Semantic analysis updated for newly parsed tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 17, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing fix/parser-using-of-for-statement (bad5823) with main (830b757)

Summary

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Jan 18, 2026
## Summary

- Fix parsing of `for (using of = null;;)` as a using declaration where `of` is the binding identifier
- Previously, the parser incorrectly treated `of` as the keyword starting a for-of loop

The fix uses a lookahead to check if the token after `of` is `=`, `;`, or `:`, matching TypeScript's parser behavior.

## Test plan

- `cargo coverage -- parser` - conformance tests pass
- `cargo test -p oxc_parser` - unit tests pass

🤖 Generated with [Claude Code](https://claude.ai/code)
@graphite-app graphite-app bot force-pushed the fix/parser-using-of-for-statement branch from bad5823 to c98e5b7 Compare January 18, 2026 00:42
@graphite-app graphite-app bot merged commit c98e5b7 into main Jan 18, 2026
22 checks passed
@graphite-app graphite-app bot deleted the fix/parser-using-of-for-statement branch January 18, 2026 00:48
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 18, 2026
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.

2 participants