Skip to content

fix(semantic): rebind class expressions before identifier checks#20916

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-31-fix_semantic_rebind_class_expressions_before_identifier_checks
Apr 1, 2026
Merged

fix(semantic): rebind class expressions before identifier checks#20916
graphite-app[bot] merged 1 commit intomainfrom
c/03-31-fix_semantic_rebind_class_expressions_before_identifier_checks

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 31, 2026

fixes #20915

broke in 2191ae9

Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 31, 2026


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 changes, fast-track this PR to the front of the merge queue

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.

@github-actions github-actions bot added A-semantic Area - Semantic C-bug Category - Bug labels Mar 31, 2026
@camc314 camc314 marked this pull request as ready for review March 31, 2026 20:08
@camc314 camc314 requested a review from Dunqing as a code owner March 31, 2026 20:08
Copilot AI review requested due to automatic review settings March 31, 2026 20:08
Copy link
Copy Markdown
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 SemanticBuilder::build() panic when running semantic analysis multiple times on the same AST (regression from commit 2191ae9f8d6d4af7a17cd01345ea6c19ca17b38e), specifically involving named class expressions with syntax checks enabled.

Changes:

  • Reorders visit_class so named class expressions are bound in the class scope before visiting/checking the identifier.
  • Adds a regression test that builds semantics twice on the same parsed program with with_check_syntax_error(true) enabled.

Reviewed changes

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

File Description
crates/oxc_semantic/src/builder.rs Binds class expressions prior to identifier visitation to avoid stale symbol_id usage on repeated builds.
crates/oxc_semantic/src/lib.rs Adds regression test ensuring repeated semantic builds don’t panic and produce no errors for the repro case.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 31, 2026

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing c/03-31-fix_semantic_rebind_class_expressions_before_identifier_checks (6e58b9b) with main (6eb77ec)

Open in CodSpeed

Footnotes

  1. 8 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.

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Apr 1, 2026
Copy link
Copy Markdown
Member

Dunqing commented Apr 1, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-31-fix_semantic_rebind_class_expressions_before_identifier_checks branch from 6e58b9b to 31316c8 Compare April 1, 2026 02:08
@graphite-app graphite-app bot merged commit 31316c8 into main Apr 1, 2026
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 1, 2026
@graphite-app graphite-app bot deleted the c/03-31-fix_semantic_rebind_class_expressions_before_identifier_checks branch April 1, 2026 02:11
leaysgur pushed a commit that referenced this pull request Apr 7, 2026
### 🐛 Bug Fixes

- fc7f60c allocator: Revert changes to
`get_current_chunk_footer_field_offset` (#20964) (overlookmotel)
- 31316c8 semantic: Rebind class expressions before identifier checks
(#20916) (camc314)

### ⚡ Performance

- fb52383 napi/parser, linter/plugins: Clear buffers and source texts
earlier (#21025) (overlookmotel)
- 3b7dec4 napi/parser, linter/plugins: Use `utf8Slice` for decoding
UTF-8 strings (#21022) (overlookmotel)
- 012c924 napi/parser, linter/plugins: Speed up decoding strings in raw
transfer (#21021) (overlookmotel)
- 55e1e9b napi/parser, linter/plugins: Initialize vars as 0 (#21020)
(overlookmotel)
- c25ef02 napi/parser, linter/plugins: Simplify branch condition in
`deserializeStr` (#21019) (overlookmotel)
- 9f494c3 napi/parser, linter/plugins: Raw transfer use
`String.fromCharCode` in string decoding (#21018) (overlookmotel)
- 91cf105 allocator: Increase initial chunk size from 512B to 16KB
(#20968) (overlookmotel)
- cbc0c21 allocator: Add `#[cold]` to to error handling functions
(#20967) (overlookmotel)
- 0503a78 napi/parser, linter/plugins: Faster deserialization of `raw`
fields (#20923) (overlookmotel)
- a24f75e napi/parser: Optimize string deserialization for non-ASCII
sources (#20834) (Joshua Tuddenham)

### 📚 Documentation

- c78a57a syntax: Fix typo (#21044) (camc314)
- f5e228f allocator: Fix typo in comment (#20972) (overlookmotel)
- 7159d51 allocator: Improve doc comment examples for `vec2::Vec`
(#20969) (overlookmotel)
- b1da750 allocator, data_structures: Correct comments (#20966)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-semantic Area - Semantic C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SemanticBuilder::build() panics with index out of bounds when called twice on the same AST

3 participants