Skip to content

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Nov 2, 2025

using / await using directly nested within a case or default clause are now disallowed (rbuckton/ecma262#14). This PR implements this change.

Note that TypeScript does not disallow them yet (microsoft/TypeScript#62708) and the test failing in tasks/coverage/snapshots/parser_typescript.snap is caused by that.

Copy link
Member Author

sapphi-red commented Nov 2, 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.

@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from 6340a33 to cc78960 Compare November 2, 2025 11:42
@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_single_statement_contexts branch from b1a60ed to abfe820 Compare November 2, 2025 11:42
@sapphi-red sapphi-red requested a review from Boshen November 2, 2025 11:46
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 2, 2025

CodSpeed Performance Report

Merging #15225 will not alter performance

Comparing 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause (693d569) with main (8b14ec9)

Summary

✅ 37 untouched

@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from cc78960 to 6da43e8 Compare November 2, 2025 11:59
@github-actions github-actions bot added A-linter Area - Linter A-transformer Area - Transformer / Transpiler labels Nov 2, 2025
@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_single_statement_contexts branch from abfe820 to 25d0dfe Compare November 2, 2025 12:11
@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from 6da43e8 to 17042fc Compare November 2, 2025 12:11
@graphite-app graphite-app bot changed the base branch from 11-02-fix_parser_reject_using___await_using_in_single_statement_contexts to graphite-base/15225 November 2, 2025 12:12
@graphite-app graphite-app bot force-pushed the graphite-base/15225 branch from 25d0dfe to 4668004 Compare November 2, 2025 12:21
@graphite-app graphite-app bot force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from 17042fc to ffc06fc Compare November 2, 2025 12:21
@graphite-app graphite-app bot changed the base branch from graphite-base/15225 to main November 2, 2025 12:21
@graphite-app graphite-app bot force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from ffc06fc to 7760a15 Compare November 2, 2025 12:21
@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from 7760a15 to 693d569 Compare November 2, 2025 12:37
@sapphi-red sapphi-red marked this pull request as ready for review November 2, 2025 12:43
@sapphi-red sapphi-red requested a review from camc314 as a code owner November 2, 2025 12:43
Copilot AI review requested due to automatic review settings November 2, 2025 12:43
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 implements validation to prevent using and await using declarations from appearing directly in bare case statements of switch statements, as per the ECMAScript specification. The parser now emits an error with a helpful suggestion to wrap such declarations in a block statement.

  • Added syntax error detection for using/await using declarations in bare switch case statements
  • Introduced new diagnostic error message with helpful guidance
  • Updated test snapshots to reflect new validation behavior

Reviewed Changes

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

Show a summary per file
File Description
crates/oxc_parser/src/js/statement.rs Adds validation logic to detect using declarations in bare switch cases
crates/oxc_parser/src/diagnostics.rs Defines new error diagnostic for invalid using declarations in switch cases
tasks/transform_conformance/snapshots/babel.snap.md Updates babel transform test results with new error messages
tasks/coverage/snapshots/parser_typescript.snap Updates TypeScript parser test results with new validation
tasks/coverage/snapshots/parser_babel.snap Updates Babel parser test results showing improved negative test coverage
tasks/coverage/snapshots/semantic_typescript.snap Updates TypeScript semantic analysis results
tasks/coverage/snapshots/formatter_typescript.snap Updates formatter test results
tasks/coverage/snapshots/estree_typescript.snap Updates ESTree test results
crates/oxc_linter/src/snapshots/eslint_no_case_declarations.snap Updates linter snapshot showing parser errors now take precedence

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

@Boshen
Copy link
Member

Boshen commented Nov 2, 2025

Need Test262 before we land.

@Boshen
Copy link
Member

Boshen commented Nov 2, 2025

@sapphi-red can you remove this from the stack.

@Boshen Boshen marked this pull request as draft November 2, 2025 15:27
@Boshen
Copy link
Member

Boshen commented Nov 2, 2025

Saw the title: tc39/test262#4498

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Nov 3, 2025
@sapphi-red sapphi-red force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from 693d569 to d70c918 Compare November 8, 2025 08:22
@Boshen Boshen marked this pull request as ready for review November 8, 2025 10:27
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 8, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Nov 8, 2025
…ault` clause (#15225)

`using` / `await using` directly nested within a `case` or `default` clause are now disallowed (rbuckton/ecma262#14). This PR implements this change.

Note that TypeScript does not disallow them yet (microsoft/TypeScript#62708) and the test failing in `tasks/coverage/snapshots/parser_typescript.snap` is caused by that.
@graphite-app graphite-app bot force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from d70c918 to bae3271 Compare November 8, 2025 10:27
@Boshen
Copy link
Member

Boshen commented Nov 8, 2025

Let's merge to avoid merge conflicts. Also because babel and acorn has implemented this.

@Boshen Boshen added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Nov 8, 2025
…ault` clause (#15225)

`using` / `await using` directly nested within a `case` or `default` clause are now disallowed (rbuckton/ecma262#14). This PR implements this change.

Note that TypeScript does not disallow them yet (microsoft/TypeScript#62708) and the test failing in `tasks/coverage/snapshots/parser_typescript.snap` is caused by that.
@graphite-app graphite-app bot force-pushed the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch from bae3271 to 732205e Compare November 8, 2025 10:29
@graphite-app graphite-app bot merged commit 732205e into main Nov 8, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 11-02-fix_parser_reject_using___await_using_in_a_switch_case___default_clause branch November 8, 2025 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-linter Area - Linter A-parser Area - Parser A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants