Skip to content

Conversation

@Renegade334
Copy link
Contributor

As per tc39/ecma262@8e5d501, [await] using VariableStatements cannot be immediate children of case/default clauses; they must be contained within a block.

Resolves #62708.

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Nov 2, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 2, 2025
@Renegade334 Renegade334 changed the title Disallow [await] using declarations under case/default clauses Disallow [await] using statements under case/default clauses Nov 2, 2025
npm go brrrrr
@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 5, 2025
);
}
else if (isVariableStatement(declarationList.parent) && isCaseOrDefaultClause(declarationList.parent.parent)) {
return grammarErrorOnNode(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised that this is not a parser error, but I guess the error above it isn't either. Fun that this means that we leave the bad node in the tree, but, that's what happens already:

//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts] ////

//// [awaitUsingDeclarationsInForIn.ts]
async function main() {
    for (await using x in {}) {
    }
}


//// [awaitUsingDeclarationsInForIn.js]
async function main() {
    for (await using x in {}) {
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye. Technically it is allowed in the ES grammar, it just triggers an early error.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct to my eye.

@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Nov 17, 2025
@jakebailey
Copy link
Member

@typescript-bot test it
@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 17, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
pack this ✅ Started ✅ Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started ✅ Results
perf test this faster ✅ Started 👀 Results

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/166565/artifacts?artifactName=tgz&fileId=6F13AC4CEB9E5076116C52E6E6C97C98A035AFC7605E7FE3524AF84CA670936702&fileName=/typescript-6.0.0-insiders.20251117.tgz"
    }
}

and then running npm install.

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user tests with tsc comparing main and refs/pull/62709/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - node (v18.15.0, x64)
Errors 1 1 ~ ~ ~ p=1.000 n=6
Symbols 62,370 62,370 ~ ~ ~ p=1.000 n=6
Types 50,386 50,386 ~ ~ ~ p=1.000 n=6
Memory used 193,922k (± 0.94%) 193,862k (± 0.96%) ~ 192,633k 196,304k p=0.748 n=6
Parse Time 1.31s (± 0.39%) 1.31s (± 0.64%) ~ 1.29s 1.31s p=0.923 n=6
Bind Time 0.72s (± 0.57%) 0.72s (± 0.75%) ~ 0.72s 0.73s p=0.282 n=6
Check Time 9.91s (± 0.43%) 9.93s (± 0.34%) ~ 9.89s 9.98s p=0.333 n=6
Emit Time 2.74s (± 0.64%) 2.74s (± 0.67%) ~ 2.73s 2.77s p=0.869 n=6
Total Time 14.68s (± 0.31%) 14.70s (± 0.26%) ~ 14.66s 14.77s p=0.165 n=6
angular-1 - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 956,047 956,047 ~ ~ ~ p=1.000 n=6
Types 415,881 415,881 ~ ~ ~ p=1.000 n=6
Memory used 1,255,013k (± 0.01%) 1,255,008k (± 0.00%) ~ 1,254,966k 1,255,083k p=0.936 n=6
Parse Time 6.54s (± 0.51%) 6.54s (± 0.68%) ~ 6.48s 6.58s p=1.000 n=6
Bind Time 1.88s (± 0.58%) 1.89s (± 0.33%) ~ 1.88s 1.90s p=0.081 n=6
Check Time 32.25s (± 0.37%) 32.47s (± 0.32%) +0.22s (+ 0.68%) 32.33s 32.59s p=0.010 n=6
Emit Time 14.88s (± 0.26%) 14.92s (± 0.34%) ~ 14.87s 15.00s p=0.334 n=6
Total Time 55.55s (± 0.27%) 55.81s (± 0.30%) +0.26s (+ 0.47%) 55.61s 56.02s p=0.045 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,665,841 2,665,841 ~ ~ ~ p=1.000 n=6
Types 922,464 922,464 ~ ~ ~ p=1.000 n=6
Memory used 2,980,350k (± 0.00%) 2,980,292k (± 0.00%) ~ 2,980,218k 2,980,356k p=0.298 n=6
Parse Time 8.42s (± 0.32%) 8.41s (± 0.31%) ~ 8.38s 8.45s p=1.000 n=6
Bind Time 2.17s (± 0.48%) 2.17s (± 0.25%) ~ 2.16s 2.17s p=0.663 n=6
Check Time 91.82s (± 0.35%) 91.78s (± 0.37%) ~ 91.17s 92.08s p=0.688 n=6
Emit Time 0.30s (± 1.79%) 0.31s ~ ~ ~ p=0.071 n=6
Total Time 102.71s (± 0.33%) 102.67s (± 0.34%) ~ 102.06s 103.00s p=0.810 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,141 1,237,110 -31 (- 0.00%) ~ ~ p=0.001 n=6
Types 259,801 259,809 +8 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,732,965k (±14.56%) 2,853,224k (±13.15%) ~ 2,367,942k 3,096,005k p=0.575 n=6
Parse Time 6.50s (± 2.01%) 6.52s (± 2.04%) ~ 6.31s 6.66s p=1.000 n=6
Bind Time 2.16s (± 2.33%) 2.17s (± 1.38%) ~ 2.13s 2.21s p=1.000 n=6
Check Time 42.84s (± 0.37%) 42.88s (± 0.37%) ~ 42.65s 43.09s p=0.936 n=6
Emit Time 3.46s (± 1.19%) 3.51s (± 1.98%) ~ 3.39s 3.56s p=0.172 n=6
Total Time 54.95s (± 0.49%) 55.08s (± 0.52%) ~ 54.70s 55.37s p=0.378 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,237,141 1,237,110 -31 (- 0.00%) ~ ~ p=0.001 n=6
Types 259,801 259,809 +8 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,039,549k (± 9.68%) 3,160,030k (± 0.03%) ~ 3,158,753k 3,161,489k p=0.575 n=6
Parse Time 6.73s (± 1.81%) 6.73s (± 0.76%) ~ 6.65s 6.79s p=0.630 n=6
Bind Time 2.14s (± 2.06%) 2.13s (± 0.86%) ~ 2.11s 2.16s p=0.745 n=6
Check Time 42.99s (± 0.39%) 43.08s (± 0.24%) ~ 42.97s 43.26s p=0.810 n=6
Emit Time 3.48s (± 2.68%) 3.48s (± 1.32%) ~ 3.42s 3.53s p=0.471 n=6
Total Time 55.35s (± 0.49%) 55.45s (± 0.12%) ~ 55.36s 55.55s p=0.688 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,364 262,311 -53 (- 0.02%) ~ ~ p=0.001 n=6
Types 103,960 103,966 +6 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 440,551k (± 0.01%) 440,535k (± 0.01%) ~ 440,488k 440,581k p=0.575 n=6
Parse Time 2.82s (± 0.62%) 2.82s (± 0.49%) ~ 2.80s 2.84s p=0.803 n=6
Bind Time 1.13s (± 0.74%) 1.13s (± 0.56%) ~ 1.12s 1.14s p=0.340 n=6
Check Time 16.06s (± 0.29%) 16.05s (± 0.25%) ~ 15.99s 16.10s p=0.872 n=6
Emit Time 1.32s (± 0.75%) 1.30s (± 0.93%) -0.02s (- 1.64%) 1.28s 1.31s p=0.016 n=6
Total Time 21.32s (± 0.22%) 21.30s (± 0.23%) ~ 21.21s 21.34s p=0.291 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 72 72 ~ ~ ~ p=1.000 n=6
Symbols 225,386 225,386 ~ ~ ~ p=1.000 n=6
Types 94,304 94,304 ~ ~ ~ p=1.000 n=6
Memory used 370,198k (± 0.07%) 370,042k (± 0.02%) ~ 369,958k 370,134k p=0.471 n=6
Parse Time 3.51s (± 0.96%) 3.53s (± 1.34%) ~ 3.45s 3.59s p=0.377 n=6
Bind Time 1.97s (± 1.52%) 1.97s (± 1.31%) ~ 1.93s 2.00s p=0.517 n=6
Check Time 20.64s (± 0.14%) 20.58s (± 0.28%) -0.07s (- 0.33%) 20.51s 20.66s p=0.035 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 26.13s (± 0.12%) 26.08s (± 0.26%) ~ 26.02s 26.19s p=0.199 n=6
vscode - node (v18.15.0, x64)
Errors 11 11 ~ ~ ~ p=1.000 n=6
Symbols 4,037,266 4,037,266 ~ ~ ~ p=1.000 n=6
Types 1,269,667 1,269,667 ~ ~ ~ p=1.000 n=6
Memory used 3,819,442k (± 0.00%) 3,819,554k (± 0.01%) ~ 3,819,339k 3,819,904k p=0.471 n=6
Parse Time 15.52s (± 0.59%) 15.48s (± 0.30%) ~ 15.40s 15.53s p=0.336 n=6
Bind Time 5.07s (± 0.34%) 5.07s (± 0.52%) ~ 5.03s 5.10s p=1.000 n=6
Check Time 109.74s (± 4.57%) 108.13s (± 3.85%) ~ 103.26s 112.83s p=0.936 n=6
Emit Time 43.50s (±22.60%) 43.12s (±24.30%) ~ 34.72s 61.69s p=1.000 n=6
Total Time 173.83s (± 4.98%) 171.80s (± 4.96%) ~ 162.94s 185.49s p=0.936 n=6
webpack - node (v18.15.0, x64)
Errors 40 40 ~ ~ ~ p=1.000 n=6
Symbols 379,737 379,737 ~ ~ ~ p=1.000 n=6
Types 166,566 166,566 ~ ~ ~ p=1.000 n=6
Memory used 539,372k (± 0.03%) 539,397k (± 0.01%) ~ 539,308k 539,503k p=0.936 n=6
Parse Time 4.62s (± 1.09%) 4.63s (± 0.52%) ~ 4.59s 4.65s p=0.748 n=6
Bind Time 1.96s (± 1.09%) 1.97s (± 1.46%) ~ 1.95s 2.03s p=0.139 n=6
Check Time 23.04s (± 1.12%) 22.85s (± 0.19%) -0.18s (- 0.80%) 22.79s 22.90s p=0.030 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 29.62s (± 0.78%) 29.45s (± 0.19%) ~ 29.38s 29.52s p=0.109 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 690,485 690,485 ~ ~ ~ p=1.000 n=6
Types 208,757 208,757 ~ ~ ~ p=1.000 n=6
Memory used 586,475k (± 0.02%) 586,606k (± 0.02%) +132k (+ 0.02%) 586,457k 586,763k p=0.045 n=6
Parse Time 4.20s (± 0.52%) 4.19s (± 0.78%) ~ 4.15s 4.24s p=0.746 n=6
Bind Time 1.36s (± 1.42%) 1.35s (± 0.66%) ~ 1.34s 1.36s p=0.222 n=6
Check Time 20.94s (± 1.43%) 20.56s (± 1.81%) ~ 20.27s 21.11s p=0.064 n=6
Emit Time 0.00s (±154.76%) 0.01s (±109.43%) ~ 0.00s 0.01s p=0.640 n=6
Total Time 26.51s (± 1.10%) 26.11s (± 1.47%) ~ 25.76s 26.64s p=0.092 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62709/merge:

Everything looks good!

@jakebailey
Copy link
Member

Babel and acorn already did this, so I'll merge this. Thanks for the PR!

@jakebailey jakebailey merged commit 60e99ec into microsoft:main Nov 19, 2025
33 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Nov 19, 2025
@Renegade334 Renegade334 deleted the erm-switch-statements branch November 19, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Should reject using / await using in a switch case / default clause

3 participants