Skip to content

Disable constraint reduction in intersections created by constraint hoisting #58403

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 4 commits into from
May 2, 2024

Conversation

ahejlsberg
Copy link
Member

Fixes #58370.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels May 2, 2024
@ahejlsberg
Copy link
Member Author

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 2, 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 @ahejlsberg, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

@ahejlsberg
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,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 192,851k (± 0.75%) 192,889k (± 0.73%) ~ 192,216k 195,765k p=0.471 n=6
Parse Time 1.30s (± 0.63%) 1.30s (± 0.90%) ~ 1.28s 1.31s p=0.498 n=6
Bind Time 0.72s 0.72s ~ ~ ~ p=1.000 n=6
Check Time 9.55s (± 0.35%) 9.55s (± 0.44%) ~ 9.51s 9.61s p=1.000 n=6
Emit Time 2.63s (± 0.51%) 2.63s (± 0.61%) ~ 2.61s 2.65s p=1.000 n=6
Total Time 14.21s (± 0.29%) 14.20s (± 0.42%) ~ 14.13s 14.29s p=0.810 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,322 945,322 ~ ~ ~ p=1.000 n=6
Types 408,088 408,110 +22 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,222,849k (± 0.00%) 1,222,845k (± 0.00%) ~ 1,222,799k 1,222,953k p=0.575 n=6
Parse Time 6.78s (± 0.62%) 6.79s (± 0.64%) ~ 6.73s 6.84s p=0.936 n=6
Bind Time 1.87s (± 0.65%) 1.88s (± 0.55%) ~ 1.86s 1.89s p=0.675 n=6
Check Time 31.35s (± 0.45%) 31.23s (± 0.38%) ~ 31.03s 31.34s p=0.109 n=6
Emit Time 14.59s (± 1.49%) 14.75s (± 0.82%) ~ 14.56s 14.85s p=0.128 n=6
Total Time 54.60s (± 0.34%) 54.64s (± 0.36%) ~ 54.39s 54.85s p=0.688 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,956,826 1,956,875 +49 (+ 0.00%) ~ ~ p=0.001 n=6
Types 676,443 676,637 +194 (+ 0.03%) ~ ~ p=0.001 n=6
Memory used 1,764,744k (± 0.00%) 1,765,669k (± 0.00%) +925k (+ 0.05%) 1,765,591k 1,765,721k p=0.005 n=6
Parse Time 6.69s (± 0.25%) 6.68s (± 0.21%) ~ 6.66s 6.70s p=0.869 n=6
Bind Time 2.31s (± 0.64%) 2.32s (± 0.22%) ~ 2.31s 2.32s p=0.667 n=6
Check Time 56.37s (± 0.43%) 56.24s (± 0.11%) ~ 56.18s 56.32s p=0.336 n=6
Emit Time 0.14s 0.14s (± 4.51%) ~ 0.13s 0.15s p=1.000 n=6
Total Time 65.51s (± 0.37%) 65.38s (± 0.08%) ~ 65.31s 65.43s p=0.375 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,217,318 1,217,388 +70 (+ 0.01%) ~ ~ p=0.001 n=6
Types 258,271 259,008 +737 (+ 0.29%) ~ ~ p=0.001 n=6
Memory used 2,327,333k (± 0.02%) 2,328,074k (± 0.03%) ~ 2,326,835k 2,328,636k p=0.128 n=6
Parse Time 4.91s (± 1.02%) 4.94s (± 0.93%) ~ 4.87s 5.00s p=0.261 n=6
Bind Time 1.88s (± 1.36%) 1.88s (± 0.80%) ~ 1.85s 1.89s p=0.871 n=6
Check Time 33.48s (± 0.31%) 33.48s (± 0.26%) ~ 33.34s 33.58s p=1.000 n=6
Emit Time 2.60s (± 0.86%) 2.63s (± 1.64%) ~ 2.58s 2.71s p=0.126 n=6
Total Time 42.89s (± 0.26%) 42.96s (± 0.35%) ~ 42.75s 43.14s p=0.471 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,217,318 1,217,388 +70 (+ 0.01%) ~ ~ p=0.001 n=6
Types 258,271 259,008 +737 (+ 0.29%) ~ ~ p=0.001 n=6
Memory used 2,402,804k (± 0.04%) 2,402,797k (± 0.02%) ~ 2,402,348k 2,403,370k p=0.575 n=6
Parse Time 7.73s (± 1.10%) 7.71s (± 0.63%) ~ 7.65s 7.79s p=1.000 n=6
Bind Time 2.47s (± 0.71%) 2.46s (± 0.56%) ~ 2.44s 2.48s p=0.411 n=6
Check Time 49.43s (± 0.20%) 49.55s (± 0.57%) ~ 49.32s 50.11s p=0.689 n=6
Emit Time 3.90s (± 4.27%) 3.87s (± 1.34%) ~ 3.79s 3.95s p=0.748 n=6
Total Time 63.54s (± 0.21%) 63.60s (± 0.42%) ~ 63.39s 64.10s p=1.000 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,297 256,310 +13 (+ 0.01%) ~ ~ p=0.001 n=6
Types 103,722 104,458 +736 (+ 0.71%) ~ ~ p=0.001 n=6
Memory used 424,323k (± 0.01%) 424,921k (± 0.01%) +599k (+ 0.14%) 424,877k 424,950k p=0.005 n=6
Parse Time 3.37s (± 0.63%) 3.38s (± 0.99%) ~ 3.34s 3.43s p=0.466 n=6
Bind Time 1.31s (± 0.64%) 1.31s (± 0.31%) ~ 1.30s 1.31s p=0.527 n=6
Check Time 17.76s (± 0.36%) 17.79s (± 0.28%) ~ 17.71s 17.83s p=0.422 n=6
Emit Time 1.36s (± 1.95%) 1.35s (± 2.04%) ~ 1.32s 1.39s p=0.516 n=6
Total Time 23.79s (± 0.22%) 23.82s (± 0.25%) ~ 23.76s 23.90s p=0.572 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,824 224,826 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 93,390 94,115 +725 (+ 0.78%) ~ ~ p=0.001 n=6
Memory used 369,308k (± 0.01%) 369,998k (± 0.03%) +690k (+ 0.19%) 369,842k 370,175k p=0.005 n=6
Parse Time 2.84s (± 0.87%) 2.83s (± 0.80%) ~ 2.79s 2.85s p=0.468 n=6
Bind Time 1.58s (± 0.53%) 1.58s (± 0.48%) ~ 1.57s 1.59s p=0.172 n=6
Check Time 15.52s (± 0.35%) 15.57s (± 0.46%) ~ 15.45s 15.64s p=0.172 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 19.95s (± 0.25%) 19.98s (± 0.35%) ~ 19.85s 20.04s p=0.261 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,801,596 2,801,607 +11 (+ 0.00%) ~ ~ p=0.001 n=6
Types 951,622 951,635 +13 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,949,564k (± 0.01%) 2,949,568k (± 0.00%) ~ 2,949,498k 2,949,676k p=0.810 n=6
Parse Time 13.51s (± 0.37%) 13.48s (± 0.11%) ~ 13.45s 13.49s p=0.085 n=6
Bind Time 4.12s (± 2.36%) 4.13s (± 2.10%) ~ 4.08s 4.30s p=0.655 n=6
Check Time 72.88s (± 0.33%) 72.81s (± 0.27%) ~ 72.49s 73.05s p=0.689 n=6
Emit Time 23.58s (± 0.99%) 23.55s (± 0.55%) ~ 23.36s 23.70s p=1.000 n=6
Total Time 114.09s (± 0.29%) 113.98s (± 0.26%) ~ 113.58s 114.26s p=0.575 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,858 265,864 +6 (+ 0.00%) ~ ~ p=0.001 n=6
Types 108,442 108,449 +7 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 410,410k (± 0.01%) 410,595k (± 0.02%) +185k (+ 0.04%) 410,493k 410,685k p=0.005 n=6
Parse Time 4.78s (± 0.98%) 4.80s (± 0.76%) ~ 4.76s 4.85s p=0.334 n=6
Bind Time 2.07s (± 0.66%) 2.07s (± 1.10%) ~ 2.03s 2.10s p=0.802 n=6
Check Time 20.99s (± 0.39%) 21.05s (± 0.29%) ~ 20.99s 21.16s p=0.422 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.84s (± 0.34%) 27.92s (± 0.12%) ~ 27.87s 27.95s p=0.148 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 524,146 524,146 ~ ~ ~ p=1.000 n=6
Types 178,732 178,737 +5 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 462,190k (± 0.02%) 462,219k (± 0.02%) ~ 462,123k 462,393k p=0.810 n=6
Parse Time 3.89s (± 0.60%) 3.89s (± 0.62%) ~ 3.86s 3.93s p=0.570 n=6
Bind Time 1.47s (± 0.96%) 1.47s (± 0.79%) ~ 1.45s 1.48s p=0.803 n=6
Check Time 22.32s (± 0.70%) 22.33s (± 0.55%) ~ 22.16s 22.48s p=1.000 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 27.67s (± 0.50%) 27.69s (± 0.42%) ~ 27.53s 27.85s p=0.873 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

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

Everything looks good!

@ahejlsberg ahejlsberg requested a review from RyanCavanaugh May 2, 2024 18:07
@ahejlsberg
Copy link
Member Author

Tests and performance all look good. This is ready to review and merge.

@@ -17467,7 +17468,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// a type alias of the form "type List<T> = T & { next: List<T> }" cannot be reduced during its declaration.
// Also, unlike union types, the order of the constituent types is preserved in order that overload resolution
// for intersections of types with signatures can be deterministic.
function getIntersectionType(types: readonly Type[], aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[], noSupertypeReduction?: boolean): Type {
function getIntersectionType(types: readonly Type[], flags = IntersectionFlags.None, aliasSymbol?: Symbol, aliasTypeArguments?: readonly Type[]): Type {
Copy link
Member

Choose a reason for hiding this comment

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

Is this flag something that should be required, in case we forget to pass it? Happens all the time for the relation intersection state...

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it's exceedingly rare to need any of these flags (only one place for each flag in entire code base), so I think it's preferable to leave it optional.

@ahejlsberg ahejlsberg merged commit 3a74ec4 into main May 2, 2024
@ahejlsberg ahejlsberg deleted the fix58370 branch May 2, 2024 23:55
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.

Constraint in generic type forgotten in assignability check
4 participants