Skip to content

Fixed signature caching issue caused by reentrant signature checking - #64077

Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:fix-63949-reentrant-signature-cache
Open

Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:fix-63949-reentrant-signature-cache

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #63949 by porting #60208 (that's basically put in the first commit in this PR).

This is basically the same as #64014 but it comes with an extra commit that doesn't regress this case:

declare const example: (f: (a: string) => number) => string;

const f = (a: string) => g();

const g = () => {
    return example(f);
};

The above should error but by porting #60208 alone, it stops doing that.

In fact, the second commit is enough to fix #63949 , the porting commit is not strictly needed for this - but I decided to keep it here as part of the Corsa-Strada alignment efforts

Copilot AI balanced review requested due to automatic review settings August 28, 2026 16:43
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Aug 28, 2026
return executeFetch("x", /*argument*/data);
}, []);
export const check: Promise<string> = cb({ v: 1 });`
for _, first := range []string{"callback", "argument", "diagnostics"} {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In here, I just make sure the cached signatures stay the same regardless of the order of the LSP requests

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.

Pull request overview

Prevents reentrant signature resolution from using a function’s inferred return type as contextual evidence for its own body.

Changes:

  • Adds the self-signature guard in contextual return-type resolution.
  • Adds compiler and Fourslash regression coverage.
  • Updates affected type, symbol, and diagnostic baselines.

Reviewed changes

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

Show a summary per file
File Description
tsc/internal/checker/checker.go Excludes a function’s own signature from contextual return typing.
tsc/internal/fourslash/tests/quickInfoGenericDefaultInReentrantCallResolution_test.go Tests stable diagnostics and quick info across request orders.
tsc/testdata/tests/cases/compiler/genericDefaultInReentrantCallResolution.ts Reproduces issue #63949.
tsc/testdata/tests/cases/compiler/reentrantCallDoesNotReuseInapplicableCachedSignature.ts Covers the related invalid-call regression.
tsc/testdata/baselines/reference/compiler/genericDefaultInReentrantCallResolution.types Records corrected inferred types.
tsc/testdata/baselines/reference/compiler/genericDefaultInReentrantCallResolution.symbols Records symbols for the regression case.
tsc/testdata/baselines/reference/compiler/reentrantCallDoesNotReuseInapplicableCachedSignature.types Records expected types for the error case.
tsc/testdata/baselines/reference/compiler/reentrantCallDoesNotReuseInapplicableCachedSignature.symbols Records expected symbols for the error case.
tsc/testdata/baselines/reference/compiler/reentrantCallDoesNotReuseInapplicableCachedSignature.errors.txt Verifies the expected assignability diagnostic.
tsc/testdata/baselines/reference/conformance/neverReturningFunctions1.types Updates affected literal widening.
tsc/testdata/baselines/reference/conformance/intraExpressionInferencesJsx.types Updates affected JSX inference baselines.

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

@@ -143,10 +143,10 @@ const Component = <T extends Animations>({
>func : () => { a: true; }

return {
>{ a: true, } : { a: true; }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think those are correct, the inferred signature here includes boolean and then that object became checked with that as its contextual part so a true literal became here contextually-typed by a boolean and that makes it to retain the true type (instead of widening to boolean)

@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Aug 30, 2026
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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-automation

Copy link
Copy Markdown
Contributor

Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-automation

Copy link
Copy Markdown
Contributor

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,276 115,276 ~ ~ ~ p=1.000 n=12
Types 79,613 79,613 ~ ~ ~ p=1.000 n=12
Memory Used 133,205k (± 0.06%) 133,215k (± 0.06%) ~ 132,979k 133,404k p=0.755 n=12
Memory Allocs 2,190,194 (± 0.00%) 2,190,268 (± 0.00%) ~ 2,190,145 2,190,604 p=0.671 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.048s (± 2.85%) 0.049s (± 4.81%) ~ 0.044s 0.056s p=0.617 n=12
Bind Time 0.015s (±12.65%) 0.016s (±13.19%) ~ 0.012s 0.022s p=0.985 n=12
Check Time 0.605s (± 0.49%) 0.595s (± 0.87%) -0.010s (- 1.60%) 0.584s 0.607s p=0.002 n=12
Emit Time 0.327s (± 2.17%) 0.321s (± 2.06%) ~ 0.308s 0.346s p=0.117 n=12
Total Time 1.002s (± 0.79%) 0.989s (± 0.78%) -0.013s (- 1.34%) 0.970s 1.014s p=0.020 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 845,225 (± 0.05%) 845,823 (± 0.03%) +598 (+ 0.07%) 845,098 846,636 p=0.024 n=12
Types 248,124 (± 0.00%) 248,124 (± 0.00%) ~ 248,122 248,127 p=0.354 n=12
Memory Used 746,018k (± 0.02%) 746,192k (± 0.01%) +174k (+ 0.02%) 745,956k 746,551k p=0.033 n=12
Memory Allocs 12,912,494 (± 0.02%) 12,915,840 (± 0.05%) ~ 12,908,954 12,946,635 p=0.478 n=12
Config Time 0.020s (± 1.59%) 0.021s (± 1.18%) ~ 0.020s 0.021s p=0.089 n=12
Parse Time 0.328s (± 1.74%) 0.324s (± 1.74%) ~ 0.306s 0.339s p=0.153 n=12
Bind Time 0.075s (± 4.59%) 0.076s (± 8.50%) ~ 0.070s 0.105s p=0.156 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.865s (± 0.68%) 1.890s (± 1.24%) ~ 1.855s 1.965s p=0.164 n=12
Total Time 2.304s (± 0.60%) 2.326s (± 1.33%) ~ 2.283s 2.441s p=0.224 n=12
mui-docs - native
Errors 11,405 11,405 ~ ~ ~ p=1.000 n=12
Symbols 4,339,337 4,339,336 -1 (- 0.00%) ~ ~ p=0.000 n=12
Types 1,379,387 1,379,387 ~ ~ ~ p=1.000 n=12
Memory Used 2,775,234k (± 0.06%) 2,775,504k (± 0.07%) ~ 2,770,435k 2,780,495k p=0.977 n=12
Memory Allocs 32,731,873 (± 0.10%) 32,730,517 (± 0.10%) ~ 32,666,178 32,850,434 p=0.843 n=12
Config Time 0.020s (± 1.59%) 0.021s (± 1.57%) ~ 0.020s 0.021s p=0.684 n=12
Parse Time 0.622s (± 1.82%) 0.629s (± 2.44%) ~ 0.588s 0.666s p=0.541 n=12
Bind Time 0.003s (±12.54%) 0.003s (±12.54%) ~ 0.002s 0.003s p=1.000 n=12
Check Time 10.634s (± 0.57%) 10.549s (± 0.25%) -0.085s (- 0.80%) 10.496s 10.632s p=0.005 n=12
Emit Time 0.578s (±12.27%) 0.595s (±12.32%) ~ 0.499s 0.787s p=0.853 n=12
Total Time 12.817s (± 0.45%) 12.765s (± 0.49%) ~ 12.629s 12.888s p=0.272 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,388,669 1,388,669 ~ ~ ~ p=1.000 n=12
Types 441,862 441,862 ~ ~ ~ p=1.000 n=12
Memory Used 1,592,313k (± 0.63%) 1,600,374k (± 0.48%) ~ 1,583,809k 1,622,870k p=0.101 n=12
Memory Allocs 82,407,529 (± 0.12%) 82,434,608 (± 0.08%) ~ 82,201,204 82,543,241 p=0.977 n=12
Config Time 0.004s (±16.32%) 0.004s (±12.82%) ~ 0.003s 0.006s p=0.543 n=12
Parse Time 0.320s (± 2.43%) 0.315s (± 2.16%) ~ 0.299s 0.333s p=0.325 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 2.166s (± 0.63%) 2.153s (± 0.39%) ~ 2.132s 2.180s p=0.147 n=12
Emit Time 0.330s (± 2.36%) 0.348s (± 5.63%) ~ 0.320s 0.404s p=0.086 n=12
Total Time 24.853s (± 0.54%) 25.034s (± 0.85%) ~ 24.583s 25.489s p=0.242 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 334,953 334,953 ~ ~ ~ p=1.000 n=12
Types 197,616 197,616 ~ ~ ~ p=1.000 n=12
Memory Used 296,023k (± 0.02%) 296,011k (± 0.03%) ~ 295,837k 296,286k p=0.932 n=12
Memory Allocs 4,621,807 (± 0.01%) 4,621,414 (± 0.01%) ~ 4,619,623 4,622,453 p=0.478 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.115s (± 3.29%) 0.114s (± 4.76%) ~ 0.102s 0.128s p=0.541 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.040s (± 0.53%) 1.045s (± 0.65%) ~ 1.030s 1.065s p=0.297 n=12
Emit Time 0.146s (± 5.55%) 0.140s (± 5.92%) ~ 0.116s 0.158s p=0.298 n=12
Total Time 1.353s (± 0.89%) 1.345s (± 1.27%) ~ 1.302s 1.378s p=0.541 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 303,834 303,834 ~ ~ ~ p=1.000 n=12
Types 181,663 181,663 ~ ~ ~ p=1.000 n=12
Memory Used 256,645k (± 0.02%) 256,678k (± 0.02%) ~ 256,614k 256,793k p=0.514 n=12
Memory Allocs 1,614,169 (± 0.01%) 1,613,973 (± 0.01%) ~ 1,613,685 1,614,553 p=0.114 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.100s (± 3.45%) 0.097s (± 5.28%) ~ 0.084s 0.115s p=0.172 n=12
Bind Time 0.039s (±10.61%) 0.040s (±11.23%) ~ 0.030s 0.052s p=1.000 n=12
Check Time 0.819s (± 0.95%) 0.812s (± 0.72%) ~ 0.800s 0.830s p=0.212 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.972s (± 0.93%) 0.963s (± 0.87%) ~ 0.939s 0.987s p=0.368 n=12
vscode - native
Errors 396 396 ~ ~ ~ p=1.000 n=12
Symbols 11,422,382 11,422,232 -150 (- 0.00%) ~ ~ p=0.000 n=12
Types 3,779,090 3,779,038 -52 (- 0.00%) ~ ~ p=0.000 n=12
Memory Used 6,511,213k (± 0.03%) 6,511,004k (± 0.01%) ~ 6,509,287k 6,512,696k p=0.443 n=12
Memory Allocs 56,068,584 (± 0.02%) 56,062,104 (± 0.01%) ~ 56,052,460 56,090,094 p=0.478 n=12
Config Time 0.075s (± 0.38%) 0.075s (± 0.36%) ~ 0.074s 0.076s p=0.366 n=12
Parse Time 1.817s (± 3.12%) 1.868s (± 3.82%) ~ 1.679s 2.035s p=0.242 n=12
Bind Time 0.633s (±18.86%) 0.550s (±17.26%) ~ 0.444s 0.900s p=0.173 n=12
Check Time 14.133s (± 1.17%) 14.262s (± 1.04%) ~ 13.848s 14.552s p=0.160 n=12
Emit Time 4.948s (±10.64%) 4.725s (± 9.63%) ~ 4.071s 5.932s p=0.579 n=12
Total Time 21.693s (± 1.97%) 21.564s (± 1.59%) ~ 20.929s 22.548s p=0.811 n=12
webpack - native
Errors 585 585 ~ ~ ~ p=1.000 n=12
Symbols 1,325,855 1,325,855 ~ ~ ~ p=1.000 n=12
Types 627,988 627,988 ~ ~ ~ p=1.000 n=12
Memory Used 951,392k (± 0.01%) 951,135k (± 0.02%) -257k (- 0.03%) 950,807k 951,622k p=0.024 n=12
Memory Allocs 6,739,043 (± 0.01%) 6,740,626 (± 0.04%) ~ 6,735,439 6,751,766 p=0.514 n=12
Config Time 0.009s 0.009s (± 5.25%) ~ 0.009s 0.011s p=0.478 n=12
Parse Time 0.306s (± 3.72%) 0.304s (± 4.31%) ~ 0.275s 0.349s p=0.681 n=12
Bind Time 0.092s (±19.62%) 0.093s (±19.62%) ~ 0.066s 0.138s p=0.966 n=12
Check Time 1.937s (± 0.43%) 1.956s (± 1.02%) ~ 1.919s 2.027s p=0.259 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.379s (± 0.56%) 2.397s (± 0.95%) ~ 2.366s 2.494s p=0.370 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,062,854 1,062,631 -223 (- 0.02%) ~ ~ p=0.000 n=12
Types 390,845 390,782 -63 (- 0.02%) ~ ~ p=0.000 n=12
Memory Used 548,055k (± 0.02%) 547,952k (± 0.02%) ~ 547,749k 548,255k p=0.128 n=12
Memory Allocs 4,891,221 (± 0.08%) 4,888,995 (± 0.07%) ~ 4,881,309 4,897,166 p=0.443 n=12
Config Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Parse Time 0.115s (± 3.22%) 0.114s (± 3.68%) ~ 0.104s 0.126s p=0.619 n=12
Bind Time 0.034s (±17.95%) 0.033s (±17.58%) ~ 0.026s 0.056s p=0.751 n=12
Check Time 0.852s (± 1.11%) 0.856s (± 0.86%) ~ 0.838s 0.876s p=0.385 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.010s (± 1.11%) 1.012s (± 0.68%) ~ 0.995s 1.024s p=0.921 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
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing baseline and pr:

Everything looks good!

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing baseline and pr:

Everything looks good!

This branch has not been deployed

No deployments
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: Not started

Development

Successfully merging this pull request may close these issues.

[7.0 regression] Type parameter default is ignored when the call sits inside a callback passed to a generic function

3 participants