Skip to content

Fixed regression in signature instantiation #59121

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

Merged
merged 2 commits into from
Jul 9, 2024

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Jul 2, 2024

fixes #59108
cc @weswigham

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jul 2, 2024
@@ -15958,7 +15958,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}

function createSignatureTypeMapper(signature: Signature, typeArguments: readonly Type[] | undefined): TypeMapper {
return createTypeMapper(signature.typeParameters!, typeArguments);
return createTypeMapper(map(signature.typeParameters!, tp => tp.mapper ? instantiateType(tp, tp.mapper) : tp), typeArguments);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that the signature might already be a product of instantiateSignature that was called without eraseTypeParameters and which thus cloned type parameters. Those cloned parameters are instantiated there in the arguments list using the available mapper but the same mapper wasn't later used when erasing type parameters from that result. This led to the mapper-instantiated cloned type parameter being left non-instantiated after erasing type parameters.

Copy link
Member

Choose a reason for hiding this comment

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

Not 100% certain, but it may be better to do sameMap here just because that would avoid extra arrays when nothing actually needs to be mapped (but maybe it doesn't happen that often).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I pushed out a commit to use sameMap here

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jul 5, 2024
@andrewbranch
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 5, 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 with tsc comparing main and refs/pull/59121/merge:

Everything looks good!

@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
Compiler-Unions - node (v18.15.0, x64)
Errors 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,153 62,153 ~ ~ ~ p=1.000 n=6
Types 50,242 50,242 ~ ~ ~ p=1.000 n=6
Memory used 192,353k (± 0.10%) 192,273k (± 0.07%) ~ 192,178k 192,559k p=0.810 n=6
Parse Time 1.31s (± 0.79%) 1.30s (± 0.93%) ~ 1.28s 1.31s p=0.720 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.42s (± 0.34%) 9.42s (± 0.36%) ~ 9.38s 9.46s p=0.936 n=6
Emit Time 2.76s (± 0.74%) 2.73s (± 1.13%) ~ 2.70s 2.78s p=0.199 n=6
Total Time 14.20s (± 0.20%) 14.17s (± 0.29%) ~ 14.12s 14.22s p=0.293 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 944,114 944,114 ~ ~ ~ p=1.000 n=6
Types 407,050 407,050 ~ ~ ~ p=1.000 n=6
Memory used 1,218,360k (± 0.00%) 1,218,632k (± 0.00%) +272k (+ 0.02%) 1,218,568k 1,218,699k p=0.005 n=6
Parse Time 6.66s (± 0.84%) 6.65s (± 0.40%) ~ 6.62s 6.69s p=1.000 n=6
Bind Time 1.87s (± 0.40%) 1.87s (± 0.59%) ~ 1.85s 1.88s p=0.604 n=6
Check Time 30.65s (± 0.41%) 30.61s (± 0.20%) ~ 30.51s 30.68s p=0.419 n=6
Emit Time 13.54s (± 0.33%) 13.54s (± 0.44%) ~ 13.45s 13.62s p=1.000 n=6
Total Time 52.71s (± 0.31%) 52.67s (± 0.20%) ~ 52.52s 52.84s p=0.688 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,130,140 2,130,140 ~ ~ ~ p=1.000 n=6
Types 927,634 927,634 ~ ~ ~ p=1.000 n=6
Memory used 2,106,235k (± 0.00%) 2,106,438k (± 0.00%) +203k (+ 0.01%) 2,106,355k 2,106,546k p=0.008 n=6
Parse Time 6.60s (± 0.33%) 6.61s (± 0.39%) ~ 6.58s 6.65s p=0.622 n=6
Bind Time 2.32s (± 0.86%) 2.31s (± 0.59%) ~ 2.28s 2.32s p=0.532 n=6
Check Time 70.66s (± 1.15%) 70.65s (± 0.21%) ~ 70.52s 70.88s p=0.173 n=6
Emit Time 0.14s (± 2.95%) 0.13s (± 3.10%) 🟩-0.01s (- 4.82%) 0.13s 0.14s p=0.034 n=6
Total Time 79.72s (± 1.01%) 79.70s (± 0.19%) ~ 79.56s 79.93s p=0.148 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,225,497 1,225,500 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,459 261,460 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,341,317k (± 0.03%) 2,341,823k (± 0.02%) ~ 2,341,408k 2,342,996k p=0.173 n=6
Parse Time 5.04s (± 1.20%) 5.04s (± 1.50%) ~ 4.93s 5.13s p=0.936 n=6
Bind Time 1.92s (± 0.51%) 1.93s (± 0.79%) ~ 1.90s 1.94s p=0.344 n=6
Check Time 34.26s (± 0.70%) 34.16s (± 0.40%) ~ 33.95s 34.32s p=0.336 n=6
Emit Time 2.64s (± 2.38%) 2.63s (± 3.57%) ~ 2.56s 2.81s p=0.470 n=6
Total Time 43.87s (± 0.52%) 43.77s (± 0.41%) ~ 43.54s 43.98s p=0.298 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,225,497 1,225,500 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 261,459 261,460 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,415,367k (± 0.04%) 2,415,583k (± 0.02%) ~ 2,414,909k 2,416,419k p=0.471 n=6
Parse Time 6.27s (± 0.60%) 6.26s (± 0.91%) ~ 6.16s 6.31s p=1.000 n=6
Bind Time 2.02s (± 0.85%) 2.02s (± 0.97%) ~ 2.00s 2.06s p=0.739 n=6
Check Time 40.66s (± 0.24%) 40.73s (± 0.13%) ~ 40.67s 40.81s p=0.173 n=6
Emit Time 3.17s (± 2.10%) 3.14s (± 2.28%) ~ 3.05s 3.26s p=0.470 n=6
Total Time 52.12s (± 0.31%) 52.17s (± 0.23%) ~ 52.02s 52.29s p=0.575 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 258,195 258,198 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Types 104,737 104,738 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 427,466k (± 0.00%) 427,804k (± 0.01%) +338k (+ 0.08%) 427,771k 427,845k p=0.005 n=6
Parse Time 3.28s (± 0.63%) 3.29s (± 0.71%) ~ 3.26s 3.32s p=0.514 n=6
Bind Time 1.33s (± 0.31%) 1.33s (± 1.03%) ~ 1.30s 1.34s p=0.753 n=6
Check Time 17.83s (± 0.45%) 17.84s (± 0.40%) ~ 17.76s 17.94s p=0.872 n=6
Emit Time 1.24s (± 0.66%) 1.26s (± 0.83%) ~ 1.24s 1.27s p=0.078 n=6
Total Time 23.69s (± 0.27%) 23.72s (± 0.41%) ~ 23.58s 23.85s p=0.630 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,565 224,565 ~ ~ ~ p=1.000 n=6
Types 93,734 93,734 ~ ~ ~ p=1.000 n=6
Memory used 369,535k (± 0.02%) 369,790k (± 0.03%) +255k (+ 0.07%) 369,588k 369,901k p=0.013 n=6
Parse Time 3.46s (± 0.55%) 3.44s (± 0.70%) ~ 3.40s 3.46s p=0.331 n=6
Bind Time 1.93s (± 0.76%) 1.95s (± 1.01%) ~ 1.93s 1.98s p=0.286 n=6
Check Time 19.13s (± 0.24%) 19.14s (± 0.20%) ~ 19.09s 19.19s p=0.572 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.52s (± 0.24%) 24.53s (± 0.25%) ~ 24.47s 24.63s p=0.688 n=6
vscode - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,882,038 2,882,038 ~ ~ ~ p=1.000 n=6
Types 975,696 975,696 ~ ~ ~ p=1.000 n=6
Memory used 3,045,281k (± 0.00%) 3,046,629k (± 0.00%) +1,349k (+ 0.04%) 3,046,536k 3,046,691k p=0.005 n=6
Parse Time 16.87s (± 0.29%) 16.89s (± 0.57%) ~ 16.80s 17.07s p=1.000 n=6
Bind Time 5.08s (± 1.83%) 5.06s (± 0.32%) ~ 5.03s 5.07s p=0.870 n=6
Check Time 90.04s (± 2.20%) 90.46s (± 3.24%) ~ 88.19s 94.59s p=0.936 n=6
Emit Time 27.94s (± 6.70%) 27.54s (± 8.73%) ~ 24.44s 29.52s p=0.936 n=6
Total Time 139.93s (± 0.23%) 139.94s (± 0.42%) ~ 139.21s 140.94s p=0.810 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 267,117 267,117 ~ ~ ~ p=1.000 n=6
Types 108,775 108,775 ~ ~ ~ p=1.000 n=6
Memory used 411,544k (± 0.03%) 411,767k (± 0.02%) +223k (+ 0.05%) 411,701k 411,892k p=0.005 n=6
Parse Time 4.68s (± 0.42%) 4.70s (± 0.29%) ~ 4.69s 4.72s p=0.059 n=6
Bind Time 2.09s (± 0.52%) 2.08s (± 0.71%) ~ 2.06s 2.10s p=0.186 n=6
Check Time 20.79s (± 0.41%) 20.79s (± 0.19%) ~ 20.74s 20.85s p=0.630 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.57s (± 0.31%) 27.57s (± 0.17%) ~ 27.52s 27.62s p=0.747 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 525,251 525,251 ~ ~ ~ p=1.000 n=6
Types 178,574 178,574 ~ ~ ~ p=1.000 n=6
Memory used 462,784k (± 0.05%) 463,167k (± 0.09%) ~ 462,672k 463,587k p=0.229 n=6
Parse Time 3.18s (± 0.65%) 3.18s (± 0.71%) ~ 3.14s 3.21s p=0.934 n=6
Bind Time 1.17s 1.17s (± 0.84%) ~ 1.16s 1.19s p=1.000 n=6
Check Time 17.93s (± 0.46%) 17.89s (± 0.36%) ~ 17.84s 18.02s p=0.687 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.27s (± 0.44%) 22.25s (± 0.31%) ~ 22.17s 22.37s p=0.748 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

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

Everything looks good!

@weswigham weswigham merged commit c9dd98e into microsoft:main Jul 9, 2024
29 checks passed
@Andarist Andarist deleted the fix/sig-erasing-instantiation branch July 9, 2024 18:35
@andrewbranch
Copy link
Member

@typescript-bot cherry-pick to release-5.5

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 9, 2024

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

Command Status Results
cherry-pick to release-5.5 ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @andrewbranch! I've created #59204 for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Regression in types after v5.5
6 participants