Skip to content

Fixed anyFunctionType leak #61980

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

fixes #61979

@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 22:30
@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
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 pull request fixes a bug that caused an anyFunctionType leak in the type checker. The changes update the contextual function checking logic and refine the checkMode usage to prevent caching of unintended return types.

  • Default checkMode is now explicitly provided in the function signature.
  • Simplified conditional checks and modified the return type computation to mask out CheckMode.SkipContextSensitive.

Reviewed Changes

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

File Description
tests/cases/compiler/contextualTypingGenericFunction2.ts Added tests to verify that inappropriate type inference in callback functions is now caught.
tests/baselines/reference/contextualTypingGenericFunction2.* Updated baselines to match the expected errors from the fixed type checking logic.
src/compiler/checker.ts Updated contextuallyCheckFunctionExpressionOrObjectLiteralMethod to use default checkMode and fixed return type computation to avoid caching anyFunctionType leaks.
Comments suppressed due to low confidence (4)

src/compiler/checker.ts:9115

  • Removing the redundant existence check for checkMode improves readability now that a default is provided.
            ) {

src/compiler/checker.ts:9115

  • The explicit default value for checkMode enhances clarity; please ensure that existing call sites behave correctly with this default.
            ) {

src/compiler/checker.ts:9115

  • The simplified condition using checkMode enhances consistency with previous changes; ensure the logical behavior remains as expected.
            ) {

@jakebailey
Copy link
Member

@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/61980/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 194,759k (± 1.03%) 195,995k (± 0.73%) ~ 193,078k 196,692k p=0.173 n=6
Parse Time 1.60s (± 1.51%) 1.60s (± 0.92%) ~ 1.58s 1.62s p=0.459 n=6
Bind Time 0.88s (± 2.03%) 0.87s (± 1.92%) ~ 0.84s 0.89s p=0.285 n=6
Check Time 11.80s (± 0.79%) 11.83s (± 0.76%) ~ 11.70s 11.93s p=0.686 n=6
Emit Time 3.34s (± 3.76%) 3.33s (± 3.48%) ~ 3.25s 3.56s p=1.000 n=6
Total Time 17.62s (± 0.94%) 17.64s (± 0.64%) ~ 17.47s 17.78s p=0.630 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,228k (± 0.00%) 1,225,209k (± 0.00%) ~ 1,225,181k 1,225,231k p=0.470 n=6
Parse Time 7.93s (± 0.60%) 7.94s (± 0.56%) ~ 7.88s 7.99s p=0.747 n=6
Bind Time 2.27s (± 0.72%) 2.26s (± 0.46%) ~ 2.25s 2.28s p=0.210 n=6
Check Time 37.91s (± 0.48%) 37.91s (± 0.22%) ~ 37.74s 37.97s p=0.688 n=6
Emit Time 17.77s (± 0.40%) 17.78s (± 0.55%) ~ 17.61s 17.90s p=0.375 n=6
Total Time 65.88s (± 0.30%) 65.89s (± 0.18%) ~ 65.69s 66.02s p=1.000 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,395k (± 0.01%) 2,804,479k (± 0.00%) ~ 2,804,337k 2,804,557k p=0.810 n=6
Parse Time 10.50s (± 0.35%) 10.50s (± 0.48%) ~ 10.45s 10.58s p=1.000 n=6
Bind Time 2.73s (± 0.55%) 2.74s (± 0.72%) ~ 2.72s 2.77s p=0.934 n=6
Check Time 101.98s (± 1.24%) 101.21s (± 0.29%) ~ 100.64s 101.45s p=0.689 n=6
Emit Time 0.78s (±129.01%) 0.37s (± 2.67%) ~ 0.36s 0.38s p=0.611 n=6
Total Time 115.99s (± 1.77%) 114.81s (± 0.28%) ~ 114.19s 115.10s p=0.810 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,081 1,227,081 ~ ~ ~ p=1.000 n=6
Types 267,474 267,474 ~ ~ ~ p=1.000 n=6
Memory used 2,730,873k (±14.64%) 2,731,389k (±14.64%) ~ 2,365,119k 3,097,551k p=0.575 n=6
Parse Time 6.64s (± 1.19%) 6.60s (± 1.66%) ~ 6.46s 6.73s p=0.630 n=6
Bind Time 2.16s (± 1.30%) 2.19s (± 1.57%) ~ 2.15s 2.23s p=0.253 n=6
Check Time 42.63s (± 0.32%) 42.84s (± 0.53%) ~ 42.51s 43.17s p=0.065 n=6
Emit Time 3.55s (± 4.31%) 3.44s (± 0.95%) 🟩-0.11s (- 3.05%) 3.40s 3.48s p=0.045 n=6
Total Time 54.99s (± 0.26%) 55.06s (± 0.53%) ~ 54.66s 55.44s p=0.810 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,227,081 1,227,081 ~ ~ ~ p=1.000 n=6
Types 267,474 267,474 ~ ~ ~ p=1.000 n=6
Memory used 3,039,830k (± 9.78%) 2,918,915k (±12.90%) ~ 2,431,851k 3,163,406k p=0.810 n=6
Parse Time 6.92s (± 1.40%) 6.86s (± 1.63%) ~ 6.67s 6.95s p=0.423 n=6
Bind Time 2.18s (± 1.57%) 2.16s (± 2.18%) ~ 2.11s 2.22s p=0.520 n=6
Check Time 42.85s (± 0.63%) 43.06s (± 0.27%) ~ 42.90s 43.23s p=0.128 n=6
Emit Time 3.54s (± 2.72%) 3.60s (± 0.54%) ~ 3.58s 3.63s p=0.470 n=6
Total Time 55.48s (± 0.65%) 55.67s (± 0.15%) ~ 55.58s 55.80s p=0.470 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 262,548 262,548 ~ ~ ~ p=1.000 n=6
Types 107,156 107,156 ~ ~ ~ p=1.000 n=6
Memory used 441,957k (± 0.02%) 441,912k (± 0.02%) ~ 441,851k 442,049k p=0.298 n=6
Parse Time 3.52s (± 0.71%) 3.52s (± 0.79%) ~ 3.47s 3.55s p=1.000 n=6
Bind Time 1.33s (± 1.00%) 1.32s (± 1.35%) ~ 1.29s 1.34s p=0.458 n=6
Check Time 18.88s (± 0.29%) 18.89s (± 0.32%) ~ 18.78s 18.94s p=0.574 n=6
Emit Time 1.53s (± 1.09%) 1.52s (± 0.97%) ~ 1.50s 1.54s p=0.560 n=6
Total Time 25.26s (± 0.36%) 25.25s (± 0.23%) ~ 25.18s 25.32s p=0.872 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,137k (± 0.03%) 371,265k (± 0.08%) ~ 371,099k 371,887k p=0.261 n=6
Parse Time 3.58s (± 0.72%) 3.59s (± 0.53%) ~ 3.57s 3.61s p=1.000 n=6
Bind Time 1.97s (± 0.87%) 1.98s (± 0.95%) ~ 1.95s 2.00s p=0.627 n=6
Check Time 20.32s (± 0.25%) 20.31s (± 0.33%) ~ 20.22s 20.43s p=0.687 n=6
Emit Time 0.00s 0.00s (±244.70%) ~ 0.00s 0.01s p=0.405 n=6
Total Time 25.87s (± 0.26%) 25.88s (± 0.30%) ~ 25.78s 25.99s p=1.000 n=6
vscode - node (v18.15.0, x64)
Errors 33 33 ~ ~ ~ p=1.000 n=6
Symbols 3,499,297 3,499,297 ~ ~ ~ p=1.000 n=6
Types 1,177,214 1,177,214 ~ ~ ~ p=1.000 n=6
Memory used 3,549,841k (± 0.01%) 3,549,767k (± 0.01%) ~ 3,549,455k 3,550,012k p=0.378 n=6
Parse Time 14.98s (± 0.41%) 15.00s (± 0.31%) ~ 14.94s 15.08s p=0.747 n=6
Bind Time 4.90s (± 0.60%) 4.89s (± 0.42%) ~ 4.86s 4.92s p=1.000 n=6
Check Time 95.52s (± 3.15%) 96.59s (± 4.04%) ~ 93.48s 101.82s p=0.936 n=6
Emit Time 30.04s (± 2.34%) 30.65s (± 4.07%) ~ 29.64s 32.81s p=0.173 n=6
Total Time 145.44s (± 2.39%) 147.13s (± 2.89%) ~ 143.75s 152.75s p=0.471 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,012k (± 0.01%) 471,991k (± 0.01%) ~ 471,908k 472,090k p=0.688 n=6
Parse Time 3.58s (± 0.41%) 3.59s (± 0.58%) ~ 3.55s 3.61s p=0.373 n=6
Bind Time 1.44s (± 0.68%) 1.43s (± 0.73%) ~ 1.42s 1.45s p=0.673 n=6
Check Time 17.38s (± 0.39%) 17.36s (± 0.41%) ~ 17.26s 17.46s p=0.688 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 22.40s (± 0.26%) 22.38s (± 0.41%) ~ 22.27s 22.52s p=0.568 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,269k (± 0.03%) 570,339k (± 0.02%) ~ 570,088k 570,480k p=0.748 n=6
Parse Time 4.24s (± 0.50%) 4.25s (± 0.73%) ~ 4.20s 4.28s p=0.806 n=6
Bind Time 1.33s (± 0.41%) 1.33s (± 0.67%) ~ 1.32s 1.34s p=0.341 n=6
Check Time 20.01s (± 0.98%) 19.99s (± 1.67%) ~ 19.77s 20.66s p=0.471 n=6
Emit Time 0.00s (±244.70%) 0.00s (±244.70%) ~ 0.00s 0.01s p=1.000 n=6
Total Time 25.60s (± 0.84%) 25.56s (± 1.35%) ~ 25.36s 26.26s p=0.471 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/61980/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.

Missing errors in generic functions in context-sensitive arguments
3 participants