-
-
Notifications
You must be signed in to change notification settings - Fork 723
fix(parser): reject using / await using in a switch case / default clause
#15225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(parser): reject using / await using in a switch case / default clause
#15225
Conversation
6340a33 to
cc78960
Compare
b1a60ed to
abfe820
Compare
CodSpeed Performance ReportMerging #15225 will not alter performanceComparing Summary
|
cc78960 to
6da43e8
Compare
abfe820 to
25d0dfe
Compare
6da43e8 to
17042fc
Compare
25d0dfe to
4668004
Compare
17042fc to
ffc06fc
Compare
ffc06fc to
7760a15
Compare
7760a15 to
693d569
Compare
There was a problem hiding this 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.
|
Need Test262 before we land. |
|
@sapphi-red can you remove this from the stack. |
|
Saw the title: tc39/test262#4498 |
693d569 to
d70c918
Compare
Merge activity
|
…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.
d70c918 to
bae3271
Compare
|
Let's merge to avoid merge conflicts. Also because babel and acorn has implemented this. |
…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.
bae3271 to
732205e
Compare

using/await usingdirectly nested within acaseordefaultclause 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.snapis caused by that.