Skip to content

Properly disallow yield in bodyless arrows #61976

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

No description provided.

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 12:52
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Jun 30, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jun 30, 2025
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

1 similar comment
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copy link

@Copilot 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 ensures that yield expressions are disallowed in concise (bodyless) arrow function bodies as required by the ES6 spec and adds a corresponding test case.

  • Disable the yield parsing context when parsing arrow expression bodies
  • Add a conformance test and update baselines to validate that yield in a bodyless arrow yields an error
  • Update .types, .symbols, .js, and .errors.txt baselines to reflect the new error

Reviewed Changes

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

Show a summary per file
File Description
src/compiler/parser.ts Disable yield context around arrow body parsing and restore afterward
tests/cases/conformance/es6/yieldExpressions/YieldExpression20_es6.ts New test case verifying yield is disallowed in a concise arrow
tests/baselines/reference/YieldExpression20_es6.types Updated type-checking baseline for the new test
tests/baselines/reference/YieldExpression20_es6.symbols Updated symbol baseline for the new test
tests/baselines/reference/YieldExpression20_es6.js Updated transpiled JS baseline for the new test
tests/baselines/reference/YieldExpression20_es6.errors.txt Updated error-message baseline for the new test
Comments suppressed due to low confidence (2)

src/compiler/parser.ts:5562

  • [nitpick] Add a brief comment explaining that we temporarily disable the yield parsing context here to enforce the ES6 rule that concise arrow bodies are not generator bodies.
        const savedYieldContext = inYieldContext();

src/compiler/parser.ts:5563

  • [nitpick] Consider using a doOutsideOfContext(NodeFlags.YieldContext, ...) helper (similar to await) to encapsulate context toggling, improving consistency and readability.
        setYieldContext(false);

@jakebailey
Copy link
Member

Pretty sure this is correct but

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 30, 2025

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

Command Status 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, 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/61976/merge:

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 34 34 ~ ~ ~ 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 196,418k (± 0.23%) 195,371k (± 0.93%) ~ 193,005k 196,675k p=0.230 n=6
Parse Time 1.61s (± 1.24%) 1.61s (± 0.64%) ~ 1.59s 1.62s p=0.744 n=6
Bind Time 0.88s (± 1.73%) 0.87s (± 1.18%) ~ 0.86s 0.89s p=0.737 n=6
Check Time 11.80s (± 0.47%) 11.77s (± 0.70%) ~ 11.68s 11.90s p=0.295 n=6
Emit Time 3.32s (± 2.10%) 3.31s (± 3.89%) ~ 3.23s 3.57s p=0.423 n=6
Total Time 17.60s (± 0.65%) 17.55s (± 0.97%) ~ 17.36s 17.81s p=0.422 n=6
angular-1 - node (v18.15.0, x64)
Errors 56 56 ~ ~ ~ p=1.000 n=6
Symbols 948,753 948,753 ~ ~ ~ p=1.000 n=6
Types 410,846 410,846 ~ ~ ~ p=1.000 n=6
Memory used 1,225,046k (± 0.01%) 1,225,044k (± 0.00%) ~ 1,225,006k 1,225,102k p=0.872 n=6
Parse Time 6.57s (± 0.81%) 6.56s (± 0.76%) ~ 6.47s 6.61s p=0.517 n=6
Bind Time 1.88s 1.88s ~ ~ ~ p=1.000 n=6
Check Time 31.85s (± 0.25%) 31.96s (± 0.52%) ~ 31.80s 32.17s p=0.335 n=6
Emit Time 14.80s (± 0.26%) 14.85s (± 0.43%) ~ 14.77s 14.94s p=0.199 n=6
Total Time 55.11s (± 0.18%) 55.25s (± 0.30%) ~ 54.99s 55.45s p=0.109 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,509,183 2,509,183 ~ ~ ~ p=1.000 n=6
Types 892,716 892,716 ~ ~ ~ p=1.000 n=6
Memory used 2,804,461k (± 0.00%) 2,804,500k (± 0.00%) ~ 2,804,361k 2,804,603k p=0.378 n=6
Parse Time 10.52s (± 0.28%) 10.48s (± 0.38%) ~ 10.43s 10.52s p=0.148 n=6
Bind Time 2.74s (± 0.68%) 2.74s (± 0.30%) ~ 2.74s 2.76s p=0.275 n=6
Check Time 101.07s (± 0.50%) 101.64s (± 1.20%) ~ 100.74s 103.40s p=0.689 n=6
Emit Time 0.37s (± 2.04%) 0.36s (± 2.29%) ~ 0.36s 0.38s p=0.432 n=6
Total Time 114.70s (± 0.46%) 115.24s (± 1.04%) ~ 114.36s 116.93s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,080 1,227,081 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 267,443 267,443 ~ ~ ~ p=1.000 n=6
Memory used 2,362,966k (± 0.05%) 2,363,185k (± 0.02%) ~ 2,362,212k 2,363,762k p=0.689 n=6
Parse Time 5.19s (± 1.13%) 5.17s (± 0.85%) ~ 5.10s 5.23s p=0.470 n=6
Bind Time 1.79s (± 0.96%) 1.80s (± 0.83%) ~ 1.79s 1.83s p=0.218 n=6
Check Time 35.24s (± 0.31%) 35.33s (± 0.68%) ~ 35.15s 35.80s p=0.936 n=6
Emit Time 2.94s (± 2.36%) 2.99s (± 1.52%) ~ 2.96s 3.08s p=0.295 n=6
Total Time 45.16s (± 0.35%) 45.32s (± 0.48%) ~ 45.15s 45.74s p=0.149 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,080 1,227,081 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 267,443 267,443 ~ ~ ~ p=1.000 n=6
Memory used 2,821,659k (±13.31%) 2,917,494k (±12.91%) ~ 2,430,770k 3,162,038k p=1.000 n=6
Parse Time 6.78s (± 1.34%) 6.81s (± 1.59%) ~ 6.66s 6.91s p=0.423 n=6
Bind Time 2.16s (± 1.64%) 2.17s (± 1.07%) ~ 2.13s 2.19s p=0.628 n=6
Check Time 42.69s (± 0.91%) 42.89s (± 0.30%) ~ 42.68s 43.05s p=0.378 n=6
Emit Time 3.52s (± 2.18%) 3.55s (± 3.58%) ~ 3.39s 3.72s p=0.810 n=6
Total Time 55.15s (± 0.76%) 55.43s (± 0.25%) ~ 55.18s 55.58s p=0.230 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,529 262,530 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Types 107,150 107,150 ~ ~ ~ p=1.000 n=6
Memory used 441,786k (± 0.01%) 441,824k (± 0.01%) ~ 441,767k 441,911k p=0.295 n=6
Parse Time 3.52s (± 1.01%) 3.54s (± 0.99%) ~ 3.50s 3.59s p=0.259 n=6
Bind Time 1.32s (± 1.31%) 1.33s (± 0.74%) ~ 1.32s 1.34s p=0.154 n=6
Check Time 18.92s (± 0.38%) 18.84s (± 0.38%) ~ 18.78s 18.95s p=0.127 n=6
Emit Time 1.52s (± 1.31%) 1.51s (± 0.90%) ~ 1.49s 1.53s p=0.564 n=6
Total Time 25.29s (± 0.24%) 25.23s (± 0.25%) ~ 25.12s 25.31s p=0.167 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 71 71 ~ ~ ~ p=1.000 n=6
Symbols 225,367 225,367 ~ ~ ~ p=1.000 n=6
Types 94,290 94,290 ~ ~ ~ p=1.000 n=6
Memory used 371,109k (± 0.01%) 371,095k (± 0.03%) ~ 370,995k 371,277k p=0.336 n=6
Parse Time 2.90s (± 0.92%) 2.88s (± 0.93%) ~ 2.83s 2.91s p=0.222 n=6
Bind Time 1.60s (± 0.92%) 1.59s (± 0.65%) ~ 1.58s 1.61s p=0.616 n=6
Check Time 16.34s (± 0.15%) 16.38s (± 0.37%) ~ 16.32s 16.49s p=0.196 n=6
Emit Time 0.00s 0.00s (±154.76%) ~ 0.00s 0.01s p=0.174 n=6
Total Time 20.83s (± 0.15%) 20.84s (± 0.25%) ~ 20.78s 20.93s p=0.568 n=6
vscode - node (v18.15.0, x64)
Errors 33 33 ~ ~ ~ p=1.000 n=6
Symbols 3,498,707 3,498,707 ~ ~ ~ p=1.000 n=6
Types 1,176,728 1,176,728 ~ ~ ~ p=1.000 n=6
Memory used 3,548,757k (± 0.00%) 3,548,727k (± 0.00%) ~ 3,548,639k 3,548,803k p=0.575 n=6
Parse Time 15.01s (± 0.92%) 15.06s (± 0.59%) ~ 14.95s 15.20s p=0.148 n=6
Bind Time 4.89s (± 0.59%) 4.90s (± 0.61%) ~ 4.85s 4.94s p=0.627 n=6
Check Time 96.25s (± 3.01%) 94.93s (± 1.75%) ~ 93.90s 98.29s p=0.378 n=6
Emit Time 30.01s (± 2.40%) 31.10s (± 7.96%) ~ 29.54s 35.98s p=0.689 n=6
Total Time 146.17s (± 2.50%) 145.99s (± 2.09%) ~ 143.29s 150.27s p=1.000 n=6
webpack - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 318,019 318,019 ~ ~ ~ p=1.000 n=6
Types 137,705 137,705 ~ ~ ~ p=1.000 n=6
Memory used 472,210k (± 0.02%) 472,126k (± 0.02%) ~ 471,931k 472,229k p=0.173 n=6
Parse Time 4.36s (± 0.45%) 4.35s (± 0.57%) ~ 4.32s 4.39s p=0.519 n=6
Bind Time 1.78s (± 1.49%) 1.76s (± 1.26%) ~ 1.73s 1.78s p=0.166 n=6
Check Time 20.79s (± 0.45%) 20.78s (± 0.44%) ~ 20.65s 20.85s p=0.936 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 26.92s (± 0.36%) 26.89s (± 0.35%) ~ 26.76s 27.01s p=0.574 n=6
xstate-main - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 665,978 665,978 ~ ~ ~ p=1.000 n=6
Types 199,345 199,345 ~ ~ ~ p=1.000 n=6
Memory used 570,384k (± 0.01%) 570,349k (± 0.03%) ~ 569,999k 570,510k p=0.936 n=6
Parse Time 4.25s (± 0.58%) 4.27s (± 0.64%) ~ 4.23s 4.30s p=0.124 n=6
Bind Time 1.33s (± 1.02%) 1.33s (± 1.32%) ~ 1.31s 1.36s p=1.000 n=6
Check Time 19.94s (± 0.46%) 19.92s (± 0.43%) ~ 19.81s 20.03s p=0.747 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 25.52s (± 0.41%) 25.53s (± 0.40%) ~ 25.39s 25.66s p=0.936 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/61976/merge:

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

3 participants