Skip to content

fix(semantic): report error on await-using inside nested static block#20746

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-25-fix_parser_report_error_on_await-using_inside_nested_static_block
Mar 25, 2026
Merged

fix(semantic): report error on await-using inside nested static block#20746
graphite-app[bot] merged 1 commit intomainfrom
c/03-25-fix_parser_report_error_on_await-using_inside_nested_static_block

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 25, 2026

Fixes missing errors on the following case:

class C {
    static {
        {
            await using y = null;
        }
    }
}

Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 25, 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 25, 2026
@camc314 camc314 marked this pull request as ready for review March 25, 2026 17:51
@camc314 camc314 requested a review from Dunqing as a code owner March 25, 2026 17:51
Copilot AI review requested due to automatic review settings March 25, 2026 17:51
@camc314 camc314 changed the title fix(parser): report error on await-using inside nested static block fix(semantic): report error on await-using inside nested static block Mar 25, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 25, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-25-fix_parser_report_error_on_await-using_inside_nested_static_block (6cccc2e) with main (c5c7210)

Open in CodSpeed

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.

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

Updates the semantic checks so await using declarations inside nested scopes of a class static initialization block correctly produce an error, aligning behavior with TypeScript’s conformance expectations.

Changes:

  • Expand the class-static-block detection for await using declarations by walking scope ancestors (stopping at function boundaries).
  • Add a reusable is_in_class_static_block helper to support the new behavior.
  • Update the TypeScript parser coverage snapshot to include the new diagnostic output.

Reviewed changes

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

File Description
tasks/coverage/snapshots/parser_typescript.snap Snapshot updated to include the new “Cannot use 'await using' in class static initialization block” diagnostic.
crates/oxc_semantic/src/checker/javascript.rs Introduces ancestor-based class static block detection and uses it for await using variable declarations.

@camc314 camc314 self-assigned this Mar 25, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 25, 2026
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 25, 2026

Merge activity

…#20746)

Fixes missing errors on the following case:
```ts
class C {
    static {
        {
            await using y = null;
        }
    }
}
```
@graphite-app graphite-app bot force-pushed the c/03-25-fix_parser_report_error_on_await-using_inside_nested_static_block branch from 6cccc2e to 2bad7f5 Compare March 25, 2026 18:28
@graphite-app graphite-app bot merged commit 2bad7f5 into main Mar 25, 2026
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 25, 2026
@graphite-app graphite-app bot deleted the c/03-25-fix_parser_report_error_on_await-using_inside_nested_static_block branch March 25, 2026 18:32
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.

2 participants