Skip to content

Fixed anyFunctionType leak - #64131

Merged
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
Andarist:fix/any-function-type-leak-go
Sep 2, 2026
Merged

Fixed anyFunctionType leak#64131
Jake Bailey (jakebailey) merged 2 commits into
microsoft:mainfrom
Andarist:fix/any-function-type-leak-go

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

recreates #61980
fixes #61979

Copilot AI balanced review requested due to automatic review settings September 2, 2026 09:49
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 2, 2026
@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug labels Sep 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Two regression cases duplicate fn coverage instead of exercising the intended fn2 scenarios.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes cached anyFunctionType leakage during contextual return-type computation.

Changes:

  • Recomputes return types without CheckModeSkipContextSensitive.
  • Adds compiler regression cases and diagnostic/type/symbol baselines.
File summaries
File Description
tsc/internal/checker/checker.go Prevents context-sensitive return types from leaking anyFunctionType.
tsc/testdata/tests/cases/compiler/contextualTypingGenericFunction2.ts Adds regression scenarios.
tsc/testdata/baselines/reference/compiler/contextualTypingGenericFunction2.errors.txt Records expected diagnostics.
tsc/testdata/baselines/reference/compiler/contextualTypingGenericFunction2.types Records inferred types.
tsc/testdata/baselines/reference/compiler/contextualTypingGenericFunction2.symbols Records symbol information.
Review details

Suppressed comments (1)

tsc/testdata/tests/cases/compiler/contextualTypingGenericFunction2.ts:57

  • This calls fn again and duplicates result3, leaving the corresponding inferred incompatible-return scenario untested for fn2. Change this call to fn2 and regenerate the baselines.
export const result6 = fn({
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tsc/testdata/tests/cases/compiler/contextualTypingGenericFunction2.ts Outdated
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Sep 2, 2026

Copy link
Copy Markdown

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
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/64131/merge:

There were infrastructure failures potentially unrelated to your change:

  • 2 instances of "Package install failed"
  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@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 - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,480 ~ ~ ~ p=1.000 n=12
Types 96,945 96,945 ~ ~ ~ p=1.000 n=12
Memory Used 148,641k (± 0.61%) 149,207k (± 0.53%) ~ 146,985k 150,758k p=0.378 n=12
Memory Allocs 2,271,259 (± 0.00%) 2,271,298 (± 0.00%) ~ 2,271,116 2,271,479 p=0.443 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.040s (± 2.52%) 0.040s (± 3.66%) ~ 0.038s 0.046s p=0.142 n=12
Bind Time 0.012s (±12.23%) 0.011s (± 7.97%) ~ 0.010s 0.014s p=0.204 n=12
Check Time 0.495s (± 0.64%) 0.497s (± 1.21%) ~ 0.486s 0.519s p=0.765 n=12
Emit Time 0.273s (± 1.98%) 0.273s (± 2.70%) ~ 0.259s 0.295s p=0.722 n=12
Total Time 0.827s (± 0.56%) 0.827s (± 1.26%) ~ 0.807s 0.854s p=0.809 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 846,830 (± 0.06%) 847,166 (± 0.08%) ~ 845,358 848,915 p=0.443 n=12
Types 249,853 (± 0.00%) 249,852 (± 0.00%) ~ 249,849 249,861 p=0.232 n=12
Memory Used 793,209k (± 0.05%) 793,637k (± 0.07%) ~ 792,202k 795,224k p=0.266 n=12
Memory Allocs 12,953,477 (± 0.04%) 12,958,431 (± 0.03%) +4,954 (+ 0.04%) 12,950,397 12,972,182 p=0.006 n=12
Config Time 0.016s 0.016s ~ ~ ~ p=1.000 n=12
Parse Time 0.271s (± 2.24%) 0.275s (± 4.12%) ~ 0.245s 0.302s p=0.541 n=12
Bind Time 0.061s (± 5.71%) 0.071s (±19.96%) ~ 0.057s 0.115s p=0.508 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.635s (± 1.41%) 1.642s (± 1.26%) ~ 1.609s 1.697s p=0.369 n=12
Total Time 1.999s (± 1.30%) 2.023s (± 1.61%) ~ 1.974s 2.109s p=0.213 n=12
mui-docs - native
Errors 11,273 (± 0.04%) 11,274 (± 0.05%) ~ 11,252 11,281 p=0.414 n=12
Symbols 4,477,906 4,477,906 ~ ~ ~ p=1.000 n=12
Types 1,550,100 1,550,100 ~ ~ ~ p=1.000 n=12
Memory Used 5,373,575k (± 0.03%) 5,373,325k (± 0.03%) ~ 5,368,976k 5,377,193k p=0.713 n=12
Memory Allocs 45,791,719 (± 0.04%) 45,795,085 (± 0.05%) ~ 45,722,945 45,868,023 p=0.843 n=12
Config Time 0.016s (± 2.12%) 0.016s (± 1.98%) ~ 0.015s 0.016s p=0.680 n=12
Parse Time 0.542s (± 1.57%) 0.548s (± 1.96%) ~ 0.505s 0.565s p=0.155 n=12
Bind Time 0.002s (± 8.72%) 0.002s ~ ~ ~ p=1.000 n=12
Check Time 15.812s (± 0.37%) 15.779s (± 0.29%) ~ 15.688s 15.885s p=0.418 n=12
Emit Time 0.447s (± 2.59%) 0.451s (± 2.57%) ~ 0.430s 0.471s p=0.764 n=12
Total Time 17.568s (± 0.39%) 17.526s (± 0.38%) ~ 17.394s 17.670s p=0.443 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,252 1,394,252 ~ ~ ~ p=1.000 n=12
Types 443,418 443,418 ~ ~ ~ p=1.000 n=12
Memory Used 1,648,691k (± 0.24%) 1,650,821k (± 0.23%) ~ 1,642,610k 1,663,420k p=0.630 n=12
Memory Allocs 97,061,460 (± 0.04%) 97,081,694 (± 0.03%) ~ 97,001,212 97,169,237 p=0.630 n=12
Config Time 0.004s (±18.29%) 0.003s (±14.60%) ~ 0.002s 0.004s p=0.457 n=12
Parse Time 0.194s (± 3.07%) 0.200s (± 1.94%) +0.006s (+ 3.14%) 0.190s 0.209s p=0.032 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.817s (± 0.46%) 1.815s (± 0.25%) ~ 1.799s 1.825s p=0.434 n=12
Emit Time 0.281s (± 5.06%) 0.290s (± 4.72%) ~ 0.244s 0.314s p=0.355 n=12
Total Time 24.851s (± 0.62%) 24.974s (± 0.72%) ~ 24.438s 25.497s p=0.291 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,531 337,531 ~ ~ ~ p=1.000 n=12
Types 198,830 198,830 ~ ~ ~ p=1.000 n=12
Memory Used 319,662k (± 0.08%) 319,566k (± 0.02%) ~ 319,403k 319,779k p=0.944 n=12
Memory Allocs 4,673,374 (± 0.01%) 4,673,238 (± 0.01%) ~ 4,671,985 4,674,062 p=0.755 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.117s (± 3.46%) 0.116s (± 4.43%) ~ 0.100s 0.130s p=0.744 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.053s (± 0.59%) 1.052s (± 0.32%) ~ 1.046s 1.066s p=0.765 n=12
Emit Time 0.143s (±12.42%) 0.137s (±13.68%) ~ 0.097s 0.167s p=0.578 n=12
Total Time 1.367s (± 1.14%) 1.357s (± 1.03%) ~ 1.317s 1.380s p=0.434 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,179 305,179 ~ ~ ~ p=1.000 n=12
Types 181,876 181,876 ~ ~ ~ p=1.000 n=12
Memory Used 277,172k (± 0.02%) 277,180k (± 0.02%) ~ 277,015k 277,279k p=0.551 n=12
Memory Allocs 1,641,883 (± 0.01%) 1,641,958 (± 0.01%) ~ 1,641,669 1,642,261 p=0.514 n=12
Config Time 0.000s 0.000s (±146.91%) ~ 0.000s 0.001s p=0.478 n=12
Parse Time 0.102s (± 4.46%) 0.101s (± 3.64%) ~ 0.091s 0.109s p=0.598 n=12
Bind Time 0.037s (±10.27%) 0.035s (± 9.26%) ~ 0.029s 0.045s p=0.502 n=12
Check Time 0.839s (± 0.60%) 0.834s (± 0.76%) ~ 0.819s 0.847s p=0.339 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.992s (± 0.98%) 0.985s (± 0.54%) ~ 0.971s 0.998s p=0.416 n=12
vscode - native
Errors 347 347 ~ ~ ~ p=1.000 n=12
Symbols 8,265,607 8,265,607 ~ ~ ~ p=1.000 n=12
Types 2,846,836 2,846,836 ~ ~ ~ p=1.000 n=12
Memory Used 5,583,097k (± 0.01%) 5,582,840k (± 0.02%) ~ 5,581,341k 5,588,413k p=0.219 n=12
Memory Allocs 43,023,299 (± 0.04%) 43,014,412 (± 0.02%) ~ 43,004,109 43,060,263 p=0.242 n=12
Config Time 0.063s (± 0.29%) 0.063s (± 0.49%) ~ 0.063s 0.064s p=0.317 n=12
Parse Time 1.625s (± 2.94%) 1.628s (± 2.95%) ~ 1.534s 1.746s p=0.887 n=12
Bind Time 0.414s (±18.56%) 0.426s (±16.26%) ~ 0.348s 0.701s p=0.415 n=12
Check Time 10.103s (± 1.55%) 10.059s (± 1.66%) ~ 9.688s 10.310s p=0.920 n=12
Emit Time 3.546s (±12.25%) 3.736s (±12.79%) ~ 3.094s 4.715s p=0.326 n=12
Total Time 15.844s (± 2.02%) 16.009s (± 2.13%) ~ 15.483s 16.838s p=0.291 n=12
webpack - native
Errors 544 544 ~ ~ ~ p=1.000 n=12
Symbols 850,538 850,538 ~ ~ ~ p=1.000 n=12
Types 386,910 386,910 ~ ~ ~ p=1.000 n=12
Memory Used 653,045k (± 0.01%) 652,975k (± 0.03%) ~ 652,185k 653,275k p=0.713 n=12
Memory Allocs 4,344,434 (± 0.06%) 4,342,582 (± 0.02%) ~ 4,341,158 4,346,905 p=0.514 n=12
Config Time 0.008s 0.008s (± 4.45%) ~ 0.008s 0.010s p=1.000 n=12
Parse Time 0.211s (± 2.29%) 0.219s (± 2.00%) +0.007s (+ 3.47%) 0.205s 0.231s p=0.029 n=12
Bind Time 0.047s (±13.13%) 0.048s (±16.42%) ~ 0.041s 0.079s p=0.874 n=12
Check Time 1.271s (± 1.10%) 1.277s (± 1.42%) ~ 1.227s 1.355s p=0.755 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.562s (± 0.53%) 1.575s (± 1.04%) ~ 1.547s 1.653s p=0.090 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,022,532 1,022,532 ~ ~ ~ p=1.000 n=12
Types 376,962 376,962 ~ ~ ~ p=1.000 n=12
Memory Used 603,507k (± 0.01%) 603,509k (± 0.01%) ~ 603,346k 603,622k p=0.932 n=12
Memory Allocs 4,754,030 (± 0.03%) 4,754,022 (± 0.03%) ~ 4,749,215 4,758,918 p=0.887 n=12
Config Time 0.003s (±12.54%) 0.003s (± 8.64%) ~ 0.002s 0.003s p=0.371 n=12
Parse Time 0.147s (± 3.39%) 0.144s (± 2.59%) ~ 0.135s 0.152s p=0.354 n=12
Bind Time 0.044s (±20.71%) 0.043s (±16.52%) ~ 0.033s 0.065s p=0.944 n=12
Check Time 1.039s (± 0.84%) 1.037s (± 0.56%) ~ 1.022s 1.054s p=0.788 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.242s (± 0.98%) 1.238s (± 0.92%) ~ 1.216s 1.268s p=0.681 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/64131/merge:

Everything looks good!

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 2, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 2, 2026
Merged via the queue into microsoft:main with commit cf7b936 Sep 2, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 2, 2026
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.

Missing errors in generic functions in context-sensitive arguments

3 participants