Skip to content
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

Fix self tail call return type inference in assigned anonymous functions #58124

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Apr 8, 2024

Good old getMergedSymbol.

I briefly thought through a case where the arrow function is assigned to a let and reassigned somewhere, but for that reassignment to change the type that can be returned by the function, it would have had to have a type annotation in the first place, so this code would never run. I think this is safe. User test showed one failure from this, so latest commit limits this feature to constant references (and function declarations as before).

Fixes #58100

@andrewbranch andrewbranch marked this pull request as ready for review April 8, 2024 23:57
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 8, 2024
@andrewbranch
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 8, 2024

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 @andrewbranch, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the user tests comparing main and refs/pull/58124/merge:

Something interesting changed - please have a look.

Details

uglify-js

/mnt/ts_downloads/_/m/uglify-js/tsconfig.json

  • [NEW] error TS2339: Property 'redefined' does not exist on type 'never'.
    • /mnt/ts_downloads/_/m/uglify-js/node_modules/uglify-js/lib/compress.js(7886,45)

webpack

tsconfig.types.json

  • [MISSING] error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

@typescript-bot
Copy link
Collaborator

@andrewbranch
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
Angular - node (v18.15.0, x64)
Memory used 295,761k (± 0.01%) 295,814k (± 0.01%) +54k (+ 0.02%) 295,758k 295,841k p=0.045 n=6
Parse Time 2.65s (± 0.74%) 2.66s (± 0.86%) ~ 2.63s 2.69s p=0.684 n=6
Bind Time 0.82s (± 1.62%) 0.83s (± 1.60%) ~ 0.81s 0.85s p=0.149 n=6
Check Time 8.21s (± 0.37%) 8.18s (± 0.44%) ~ 8.14s 8.23s p=0.147 n=6
Emit Time 7.03s (± 0.32%) 7.04s (± 0.28%) ~ 7.01s 7.07s p=0.512 n=6
Total Time 18.71s (± 0.28%) 18.71s (± 0.29%) ~ 18.66s 18.80s p=0.936 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 191,702k (± 0.06%) 193,500k (± 1.00%) ~ 191,611k 195,342k p=0.230 n=6
Parse Time 1.64s (± 1.87%) 1.65s (± 0.74%) ~ 1.63s 1.66s p=0.934 n=6
Bind Time 0.87s (± 0.73%) 0.86s (± 1.21%) ~ 0.85s 0.88s p=0.388 n=6
Check Time 11.13s (± 0.32%) 11.12s (± 0.40%) ~ 11.05s 11.17s p=0.936 n=6
Emit Time 3.14s (± 0.56%) 3.13s (± 0.74%) ~ 3.09s 3.15s p=0.805 n=6
Total Time 16.77s (± 0.38%) 16.76s (± 0.34%) ~ 16.71s 16.84s p=0.573 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,682k (± 0.00%) 347,676k (± 0.00%) ~ 347,661k 347,694k p=0.377 n=6
Parse Time 2.49s (± 0.33%) 2.48s (± 0.70%) ~ 2.46s 2.51s p=0.250 n=6
Bind Time 0.89s (± 0.71%) 0.89s (± 0.00%) ~ 0.89s 0.89s p=1.000 n=6
Check Time 6.96s (± 0.25%) 6.93s (± 0.32%) -0.03s (- 0.48%) 6.90s 6.95s p=0.017 n=6
Emit Time 4.07s (± 0.26%) 4.07s (± 0.20%) ~ 4.06s 4.08s p=0.865 n=6
Total Time 14.41s (± 0.16%) 14.37s (± 0.17%) -0.04s (- 0.28%) 14.33s 14.40s p=0.029 n=6
TFS - node (v18.15.0, x64)
Memory used 302,556k (± 0.00%) 302,557k (± 0.01%) ~ 302,535k 302,603k p=0.575 n=6
Parse Time 2.96s (± 1.22%) 2.97s (± 1.06%) ~ 2.93s 3.02s p=0.520 n=6
Bind Time 1.44s (± 0.62%) 1.44s (± 0.84%) ~ 1.42s 1.45s p=0.676 n=6
Check Time 9.13s (± 0.33%) 9.14s (± 0.46%) ~ 9.07s 9.19s p=0.808 n=6
Emit Time 5.29s (± 0.49%) 5.30s (± 0.78%) ~ 5.27s 5.37s p=0.506 n=6
Total Time 18.80s (± 0.24%) 18.85s (± 0.46%) ~ 18.76s 18.99s p=0.809 n=6
material-ui - node (v18.15.0, x64)
Memory used 510,535k (± 0.01%) 510,539k (± 0.00%) ~ 510,518k 510,557k p=0.748 n=6
Parse Time 2.66s (± 0.19%) 2.66s (± 0.41%) ~ 2.64s 2.67s p=0.784 n=6
Bind Time 0.99s (± 1.23%) 0.99s (± 1.23%) ~ 0.97s 1.00s p=1.000 n=6
Check Time 17.21s (± 0.22%) 17.26s (± 0.44%) ~ 17.15s 17.38s p=0.261 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.86s (± 0.19%) 20.91s (± 0.42%) ~ 20.79s 21.03s p=0.470 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,743,857k (± 0.00%) 1,743,862k (± 0.00%) ~ 1,743,780k 1,743,900k p=0.378 n=6
Parse Time 9.64s (± 0.46%) 9.61s (± 0.72%) ~ 9.55s 9.74s p=0.149 n=6
Bind Time 3.40s (± 0.51%) 3.38s (± 0.36%) ~ 3.37s 3.40s p=0.050 n=6
Check Time 80.94s (± 0.58%) 81.14s (± 0.39%) ~ 80.70s 81.49s p=0.378 n=6
Emit Time 0.19s (± 2.13%) 0.19s (± 2.13%) ~ 0.19s 0.20s p=1.000 n=6
Total Time 94.17s (± 0.53%) 94.32s (± 0.40%) ~ 93.83s 94.82s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,299,936k (± 0.04%) 2,299,521k (± 0.05%) ~ 2,297,842k 2,300,760k p=0.471 n=6
Parse Time 7.40s (± 0.70%) 7.41s (± 0.74%) ~ 7.34s 7.48s p=0.810 n=6
Bind Time 2.72s (± 1.29%) 2.72s (± 0.86%) ~ 2.69s 2.76s p=1.000 n=6
Check Time 48.68s (± 0.24%) 48.67s (± 0.51%) ~ 48.30s 48.91s p=1.000 n=6
Emit Time 3.81s (± 3.25%) 3.85s (± 2.62%) ~ 3.73s 3.96s p=0.688 n=6
Total Time 62.62s (± 0.12%) 62.67s (± 0.42%) ~ 62.32s 62.95s p=0.471 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used 2,374,244k (± 0.02%) 2,374,132k (± 0.04%) ~ 2,372,973k 2,374,812k p=1.000 n=6
Parse Time 7.70s (± 1.56%) 7.71s (± 1.33%) ~ 7.55s 7.82s p=0.810 n=6
Bind Time 2.48s (± 0.76%) 2.48s (± 1.48%) ~ 2.43s 2.53s p=0.809 n=6
Check Time 49.14s (± 0.34%) 49.25s (± 0.32%) ~ 49.03s 49.52s p=0.471 n=6
Emit Time 3.89s (± 3.18%) 3.96s (± 3.82%) ~ 3.85s 4.25s p=0.471 n=6
Total Time 63.25s (± 0.57%) 63.43s (± 0.40%) ~ 63.09s 63.83s p=0.688 n=6
self-compiler - node (v18.15.0, x64)
Memory used 418,088k (± 0.00%) 418,095k (± 0.01%) ~ 418,047k 418,135k p=0.471 n=6
Parse Time 3.35s (± 0.45%) 3.37s (± 0.66%) ~ 3.33s 3.39s p=0.146 n=6
Bind Time 1.31s (± 1.25%) 1.30s (± 1.60%) ~ 1.27s 1.32s p=0.331 n=6
Check Time 17.79s (± 0.36%) 17.76s (± 0.38%) ~ 17.69s 17.86s p=0.335 n=6
Emit Time 1.38s (± 1.68%) 1.37s (± 1.79%) ~ 1.34s 1.40s p=0.676 n=6
Total Time 23.83s (± 0.23%) 23.80s (± 0.38%) ~ 23.68s 23.89s p=0.575 n=6
vscode - node (v18.15.0, x64)
Memory used 2,904,045k (± 0.00%) 2,904,063k (± 0.00%) ~ 2,903,949k 2,904,199k p=0.810 n=6
Parse Time 16.01s (± 0.15%) 16.01s (± 0.71%) ~ 15.90s 16.16s p=0.373 n=6
Bind Time 4.94s (± 0.40%) 4.94s (± 0.47%) ~ 4.92s 4.98s p=0.667 n=6
Check Time 86.87s (± 0.57%) 86.68s (± 0.36%) ~ 86.23s 87.05s p=0.810 n=6
Emit Time 23.70s (± 0.68%) 23.73s (± 0.50%) ~ 23.57s 23.94s p=0.335 n=6
Total Time 131.53s (± 0.36%) 131.35s (± 0.33%) ~ 130.68s 131.83s p=1.000 n=6
webpack - node (v18.15.0, x64)
Memory used 408,710k (± 0.02%) 408,649k (± 0.01%) ~ 408,567k 408,686k p=0.298 n=6
Parse Time 3.89s (± 0.65%) 3.89s (± 0.38%) ~ 3.87s 3.91s p=0.803 n=6
Bind Time 1.67s (± 0.59%) 1.66s (± 0.49%) ~ 1.65s 1.67s p=0.498 n=6
Check Time 16.70s (± 0.42%) 16.64s (± 0.28%) ~ 16.56s 16.69s p=0.064 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.26s (± 0.33%) 22.19s (± 0.25%) ~ 22.09s 22.24s p=0.173 n=6
xstate - node (v18.15.0, x64)
Memory used 670,735k (± 0.01%) 670,793k (± 0.03%) ~ 670,655k 671,197k p=0.810 n=6
Parse Time 3.33s (± 0.35%) 3.34s (± 0.25%) ~ 3.32s 3.34s p=0.555 n=6
Bind Time 1.56s (± 0.57%) 1.57s (± 0.53%) ~ 1.55s 1.57s p=0.339 n=6
Check Time 2.88s (± 0.89%) 2.89s (± 0.78%) ~ 2.88s 2.94s p=0.451 n=6
Emit Time 0.02s (±34.96%) 0.02s (± 0.00%) ~ 0.02s 0.02s p=0.405 n=6
Total Time 7.82s (± 0.26%) 7.83s (± 0.30%) ~ 7.80s 7.87s p=0.334 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - 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)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@andrewbranch Here are the results of running the top 400 repos comparing main and refs/pull/58124/merge:

Everything looks good!

@fatcerberus
Copy link

fatcerberus commented Apr 9, 2024

Hypothetically:

let foo = () => {  // :: () => number
    if (Math.random() < 0.5)
        return foo();
    else
        return 42;
};

It's true, any reassignment, even with an entirely different function, could only narrow the return type so it's not possible to introduce unsoundness that way. It's one of those things that just feels questionable but is actually (probably) totally safe

@andrewbranch
Copy link
Member Author

The missing error in Webpack is a good thing, showing how this is intended to work. The new error in uglify-js is an example of a reassignment of the outer function throwing this off. It’s allowed because noImplicitAny is off, though I guess an explicitly-any variable could be assigned to a function variable under noImplicitAny. I think I’m going to limit this to const variables.

@jakebailey
Copy link
Member

Can you extract the uglify-js case into a test, since presumably it didn't fail in CI?

I find it weird that we would want to special case const vs let here, though...

@andrewbranch
Copy link
Member Author

The uglify-js case is added in the latest commit. We could do definite assignment analysis, but I’m not sure that’s worth it? There are other narrowing features that are predicated on const-ness, IIRC.

@jakebailey
Copy link
Member

Ah, it's the var case. I was looking for some sort of error baseline but that's the opposite of right. CI is also failing, but not sure if that's related or not.

return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
return isConstantVariable(symbol)
|| isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol)
|| !!symbol.valueDeclaration && isFunctionExpression(symbol.valueDeclaration);
Copy link
Member Author

Choose a reason for hiding this comment

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

If an identifier resolved to a function expression symbol, that function had a name, and that name cannot be reassigned, so it’s effectively constant.

https://www.typescriptlang.org/play?#code/G4QwTgBCELwQZgVwHYGMAuBLA9shAKASggG8AoCSiAemogAF0BnAWgFMAPABzY3bDDYwFKvFgQUAEzbxMyNpIDcIyqlxNsAGzYA6TdgDm+eDuQgAtm0LKAvmRBFFQA

@jakebailey
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 9, 2024

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 ❌ Error: Error: Build pipeline TypeScript Parallelized On-Demand DT Tests is disabled for project TypeScript.
perf test this faster ✅ Started 👀 Results

@jakebailey
Copy link
Member

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 9, 2024

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

Command Status Results
run dt ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

webpack

tsconfig.types.json

  • [MISSING] error TS7023: 'next' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.

@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
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
Angular - node (v18.15.0, x64)
Memory used 295,913k (± 0.01%) 295,888k (± 0.00%) ~ 295,883k 295,901k p=0.468 n=6
Parse Time 2.66s (± 0.28%) 2.66s (± 0.19%) ~ 2.65s 2.66s p=0.784 n=6
Bind Time 0.82s (± 1.83%) 0.82s (± 1.26%) ~ 0.81s 0.83s p=0.417 n=6
Check Time 8.23s (± 0.10%) 8.21s (± 0.36%) ~ 8.16s 8.24s p=0.318 n=6
Emit Time 7.06s (± 0.35%) 7.07s (± 0.33%) ~ 7.02s 7.09s p=0.454 n=6
Total Time 18.77s (± 0.13%) 18.75s (± 0.24%) ~ 18.66s 18.78s p=0.517 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,479k (± 1.02%) 192,843k (± 0.93%) ~ 191,664k 195,191k p=0.471 n=6
Parse Time 1.35s (± 0.47%) 1.37s (± 1.56%) ~ 1.33s 1.39s p=0.072 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.57%) ~ 0.71s 0.72s p=0.405 n=6
Check Time 9.39s (± 0.31%) 9.40s (± 0.26%) ~ 9.36s 9.43s p=0.625 n=6
Emit Time 2.62s (± 0.72%) 2.62s (± 0.74%) ~ 2.59s 2.65s p=0.868 n=6
Total Time 14.08s (± 0.28%) 14.10s (± 0.26%) ~ 14.08s 14.17s p=0.418 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,697k (± 0.01%) 347,680k (± 0.00%) ~ 347,671k 347,691k p=0.229 n=6
Parse Time 2.48s (± 0.66%) 2.48s (± 0.21%) ~ 2.48s 2.49s p=0.794 n=6
Bind Time 0.89s (± 0.46%) 0.89s (± 0.00%) ~ 0.89s 0.89s p=0.405 n=6
Check Time 6.97s (± 0.22%) 6.94s (± 0.25%) -0.03s (- 0.38%) 6.92s 6.97s p=0.029 n=6
Emit Time 4.06s (± 0.48%) 4.05s (± 0.26%) ~ 4.04s 4.07s p=0.285 n=6
Total Time 14.41s (± 0.23%) 14.38s (± 0.11%) ~ 14.36s 14.40s p=0.107 n=6
TFS - node (v18.15.0, x64)
Memory used 302,570k (± 0.01%) 302,553k (± 0.01%) ~ 302,535k 302,577k p=0.109 n=6
Parse Time 2.98s (± 0.81%) 2.97s (± 0.45%) ~ 2.95s 2.99s p=0.558 n=6
Bind Time 1.43s (± 0.36%) 1.43s (± 0.69%) ~ 1.42s 1.45s p=0.504 n=6
Check Time 9.16s (± 0.30%) 9.16s (± 0.34%) ~ 9.11s 9.20s p=1.000 n=6
Emit Time 5.34s (± 0.74%) 5.31s (± 0.69%) ~ 5.26s 5.34s p=0.460 n=6
Total Time 18.92s (± 0.21%) 18.88s (± 0.32%) ~ 18.80s 18.96s p=0.226 n=6
material-ui - node (v18.15.0, x64)
Memory used 510,512k (± 0.00%) 510,530k (± 0.01%) ~ 510,485k 510,563k p=0.229 n=6
Parse Time 2.65s (± 0.21%) 2.66s (± 0.28%) ~ 2.65s 2.67s p=0.137 n=6
Bind Time 0.99s (± 1.65%) 0.98s (± 0.77%) ~ 0.97s 0.99s p=0.741 n=6
Check Time 17.20s (± 0.44%) 17.18s (± 0.34%) ~ 17.09s 17.25s p=0.521 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.85s (± 0.45%) 20.82s (± 0.28%) ~ 20.74s 20.90s p=0.471 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,742,671k (± 0.00%) 1,742,699k (± 0.00%) ~ 1,742,645k 1,742,742k p=0.378 n=6
Parse Time 7.87s (± 0.30%) 7.85s (± 0.69%) ~ 7.77s 7.92s p=0.625 n=6
Bind Time 2.74s (± 1.08%) 2.75s (± 1.21%) ~ 2.69s 2.78s p=0.373 n=6
Check Time 66.50s (± 0.22%) 66.37s (± 0.38%) ~ 66.00s 66.74s p=0.298 n=6
Emit Time 0.16s (± 4.75%) 0.15s (± 3.53%) ~ 0.15s 0.16s p=0.476 n=6
Total Time 77.27s (± 0.21%) 77.14s (± 0.32%) ~ 76.72s 77.45s p=0.298 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,302,677k (± 0.02%) 2,302,164k (± 0.03%) ~ 2,301,044k 2,303,094k p=0.378 n=6
Parse Time 7.46s (± 1.11%) 7.41s (± 1.02%) ~ 7.34s 7.53s p=0.261 n=6
Bind Time 2.73s (± 0.71%) 2.74s (± 0.74%) ~ 2.71s 2.77s p=0.198 n=6
Check Time 48.82s (± 0.16%) 48.99s (± 0.45%) ~ 48.78s 49.42s p=0.128 n=6
Emit Time 3.79s (± 2.52%) 3.87s (± 1.90%) ~ 3.76s 3.98s p=0.173 n=6
Total Time 62.83s (± 0.25%) 63.03s (± 0.35%) ~ 62.83s 63.44s p=0.173 n=6
self-build-src-public-api - node (v18.15.0, x64)
Memory used 2,376,670k (± 0.03%) 2,376,707k (± 0.04%) ~ 2,375,377k 2,377,694k p=0.810 n=6
Parse Time 6.22s (± 0.72%) 6.25s (± 0.91%) ~ 6.16s 6.31s p=0.336 n=6
Bind Time 2.04s (± 0.96%) 2.04s (± 0.62%) ~ 2.02s 2.05s p=0.567 n=6
Check Time 39.80s (± 0.35%) 39.87s (± 0.23%) ~ 39.74s 39.95s p=0.687 n=6
Emit Time 3.13s (± 3.21%) 3.14s (± 2.10%) ~ 3.07s 3.24s p=0.748 n=6
Total Time 51.19s (± 0.13%) 51.31s (± 0.26%) ~ 51.19s 51.46s p=0.378 n=6
self-compiler - node (v18.15.0, x64)
Memory used 418,257k (± 0.01%) 418,262k (± 0.01%) ~ 418,205k 418,336k p=0.810 n=6
Parse Time 3.38s (± 0.89%) 3.38s (± 0.78%) ~ 3.36s 3.43s p=1.000 n=6
Bind Time 1.30s (± 1.26%) 1.30s (± 1.61%) ~ 1.28s 1.33s p=0.870 n=6
Check Time 17.79s (± 0.43%) 17.89s (± 0.43%) +0.11s (+ 0.61%) 17.81s 18.01s p=0.031 n=6
Emit Time 1.37s (± 2.04%) 1.38s (± 1.09%) ~ 1.37s 1.41s p=0.331 n=6
Total Time 23.83s (± 0.31%) 23.96s (± 0.25%) +0.13s (+ 0.52%) 23.89s 24.05s p=0.020 n=6
vscode - node (v18.15.0, x64)
Memory used 2,905,420k (± 0.00%) 2,905,425k (± 0.00%) ~ 2,905,399k 2,905,474k p=1.000 n=6
Parse Time 13.00s (± 0.43%) 12.95s (± 0.35%) ~ 12.87s 12.99s p=0.376 n=6
Bind Time 4.06s (± 0.29%) 4.07s (± 0.37%) ~ 4.05s 4.09s p=0.451 n=6
Check Time 71.32s (± 0.45%) 71.25s (± 0.34%) ~ 71.00s 71.60s p=0.810 n=6
Emit Time 19.47s (± 0.42%) 19.41s (± 0.72%) ~ 19.28s 19.65s p=0.295 n=6
Total Time 107.85s (± 0.32%) 107.68s (± 0.20%) ~ 107.44s 107.94s p=0.298 n=6
webpack - node (v18.15.0, x64)
Memory used 408,635k (± 0.02%) 408,654k (± 0.01%) ~ 408,623k 408,703k p=0.873 n=6
Parse Time 3.87s (± 0.53%) 3.88s (± 0.31%) ~ 3.87s 3.90s p=0.389 n=6
Bind Time 1.66s (± 1.17%) 1.66s (± 1.12%) ~ 1.63s 1.68s p=0.805 n=6
Check Time 16.63s (± 0.33%) 16.68s (± 0.33%) ~ 16.58s 16.73s p=0.199 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.17s (± 0.31%) 22.23s (± 0.22%) ~ 22.15s 22.28s p=0.128 n=6
xstate - node (v18.15.0, x64)
Memory used 670,883k (± 0.02%) 670,863k (± 0.02%) ~ 670,742k 670,979k p=0.748 n=6
Parse Time 4.97s (± 0.35%) 4.99s (± 0.48%) ~ 4.96s 5.02s p=0.145 n=6
Bind Time 2.31s (± 0.95%) 2.30s (± 1.28%) ~ 2.26s 2.34s p=0.808 n=6
Check Time 4.23s (± 0.85%) 4.25s (± 0.84%) ~ 4.21s 4.30s p=0.572 n=6
Emit Time 0.03s (± 0.00%) 0.03s (± 0.00%) ~ 0.03s 0.03s p=1.000 n=6
Total Time 11.55s (± 0.39%) 11.58s (± 0.47%) ~ 11.53s 11.68s p=0.748 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - 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)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate - 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 comparing main and refs/pull/58124/merge:

Everything looks good!

@gabritto
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 10, 2024

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

Command Status Results
pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented Apr 10, 2024

Hey @gabritto, 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/161132/artifacts?artifactName=tgz&fileId=CB6C9AC6657D41A7DF9306429CE099AE708D9DDF05C96451D7583AD972CB52F302&fileName=/typescript-5.5.0-insiders.20240410.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@5.5.0-pr-58124-21".;

@gabritto
Copy link
Member

gabritto commented Apr 10, 2024

Is it intentional that the following example changes behavior from () => void to () => any (and errors) with this PR? https://www.staging-typescript.org/play?ts=5.5.0-pr-58124-21#code/DYUwLgBAZgdhC8EAUBKBA+CBvAsAKAmjkVQ2wgCdwBXCuAZgG4IBffQgSymQFkBDMAAsAdBT4wAJgHsAtqjS4ChSjTpFUjdq3wsgA

@andrewbranch
Copy link
Member Author

@gabritto yes. We weren’t quite getting it right before and we’re still not quite getting it right now, but I think it’s arguably slightly better now? Previously, we did identify the return fn() as a recursive tail call, because getMergedSymbol was never needed in this example. (To be honest I didn’t dig into when/why getMergedSymbol was needed in some of the other cases; I just noticed that the comparison was happening between a symbol and its merged version.) So previously, the return inside the if was eliminated to never, and falling out the bottom of the function contributed void. Now, we recognize that fn is reassigned, and so return fn() cannot be assumed to contribute never. So we try to get its return type and hit the circularity.

@gabritto
Copy link
Member

Ok, that makes sense.

@andrewbranch andrewbranch merged commit 2b038ff into microsoft:main Apr 10, 2024
25 checks passed
@andrewbranch andrewbranch deleted the bug/58100 branch April 10, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inference of recursive arrow function's return type is any
5 participants