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

Improve detection of cases where subtype reduction is unnecessary #53435

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

ahejlsberg
Copy link
Member

Fixes #53425.

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

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test faster
@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at aab1be6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at aab1be6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @ahejlsberg, I've started to run the extended test suite on this PR at aab1be6. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at aab1be6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at aab1be6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparing main and refs/pull/53435/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

Comparison Report - main..53435

Metric main 53435 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 361,412k (± 0.01%) 361,413k (± 0.01%) ~ 361,349k 361,472k p=1.000 n=6
Parse Time 3.53s (± 0.81%) 3.51s (± 1.02%) ~ 3.47s 3.56s p=0.377 n=6
Bind Time 1.18s (± 0.44%) 1.19s (± 0.69%) ~ 1.18s 1.20s p=0.523 n=6
Check Time 9.54s (± 0.69%) 9.53s (± 0.25%) ~ 9.51s 9.57s p=0.872 n=6
Emit Time 7.97s (± 0.55%) 7.93s (± 0.41%) ~ 7.90s 7.99s p=0.120 n=6
Total Time 22.22s (± 0.42%) 22.16s (± 0.15%) ~ 22.12s 22.21s p=0.374 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 193,117k (± 0.71%) 193,501k (± 0.80%) ~ 192,493k 195,888k p=1.000 n=6
Parse Time 1.60s (± 0.61%) 1.58s (± 1.24%) ~ 1.56s 1.60s p=0.128 n=6
Bind Time 0.82s (± 0.63%) 0.82s (± 0.63%) ~ 0.82s 0.83s p=1.000 n=6
Check Time 10.12s (± 0.34%) 10.14s (± 0.59%) ~ 10.07s 10.23s p=0.807 n=6
Emit Time 2.99s (± 0.85%) 3.01s (± 0.68%) ~ 2.99s 3.05s p=0.118 n=6
Total Time 15.53s (± 0.40%) 15.56s (± 0.46%) ~ 15.50s 15.67s p=0.810 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,578k (± 0.01%) 345,562k (± 0.00%) ~ 345,542k 345,578k p=0.378 n=6
Parse Time 2.73s (± 0.68%) 2.72s (± 0.49%) ~ 2.70s 2.74s p=0.112 n=6
Bind Time 1.09s (± 0.37%) 1.08s (± 0.50%) ~ 1.08s 1.09s p=0.282 n=6
Check Time 7.76s (± 0.30%) 7.75s (± 0.27%) ~ 7.72s 7.77s p=0.406 n=6
Emit Time 4.48s (± 0.73%) 4.47s (± 1.07%) ~ 4.42s 4.53s p=0.573 n=6
Total Time 16.06s (± 0.26%) 16.01s (± 0.33%) ~ 15.94s 16.08s p=0.172 n=6
TFS - node (v16.17.1, x64)
Memory used 299,820k (± 0.01%) 299,833k (± 0.01%) ~ 299,798k 299,874k p=0.575 n=6
Parse Time 2.16s (± 0.35%) 2.17s (± 0.39%) ~ 2.16s 2.18s p=0.652 n=6
Bind Time 1.25s (± 0.44%) 1.24s (± 1.14%) ~ 1.22s 1.26s p=0.498 n=6
Check Time 7.21s (± 0.38%) 7.21s (± 0.36%) ~ 7.18s 7.25s p=1.000 n=6
Emit Time 4.34s (± 0.54%) 4.34s (± 0.52%) ~ 4.32s 4.38s p=0.568 n=6
Total Time 14.96s (± 0.30%) 14.96s (± 0.16%) ~ 14.93s 14.99s p=0.936 n=6
material-ui - node (v16.17.1, x64)
Memory used 476,418k (± 0.00%) 476,441k (± 0.00%) ~ 476,418k 476,475k p=0.065 n=6
Parse Time 3.21s (± 0.23%) 3.21s (± 0.51%) ~ 3.19s 3.23s p=0.805 n=6
Bind Time 0.96s (± 0.54%) 0.96s (± 0.85%) ~ 0.95s 0.97s p=0.929 n=6
Check Time 18.16s (± 0.77%) 18.22s (± 0.30%) ~ 18.16s 18.30s p=0.228 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.33s (± 0.59%) 22.39s (± 0.27%) ~ 22.30s 22.47s p=0.229 n=6
xstate - node (v16.17.1, x64)
Memory used 550,540k (± 0.03%) 550,481k (± 0.01%) ~ 550,430k 550,599k p=0.689 n=6
Parse Time 3.95s (± 0.69%) 3.94s (± 0.25%) ~ 3.92s 3.95s p=0.871 n=6
Bind Time 1.79s (± 0.91%) 1.79s (± 0.91%) ~ 1.77s 1.82s p=1.000 n=6
Check Time 3.04s (± 0.87%) 3.04s (± 0.82%) ~ 3.00s 3.07s p=0.746 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 4.45%) ~ 0.09s 0.10s p=0.405 n=6
Total Time 8.86s (± 0.44%) 8.86s (± 0.45%) ~ 8.81s 8.92s p=0.936 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-135-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 53435 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top-repos suite comparing main and refs/pull/53435/merge:

Something interesting changed - please have a look.

Details

microsoft/vscode

4 of 53 projects failed to build with the old tsc and were ignored

src/tsconfig.tsec.json

refined-github/refined-github

tsconfig.json

@jakebailey
Copy link
Member

The new errors above actually seem... good?

@RyanCavanaugh
Copy link
Member

Looks like people who declared something with

let x: void | number;
if (maybe) {
  x = 32;
}
x;

now get an error, which they absolutely should have.

@RyanCavanaugh RyanCavanaugh added the Breaking Change Would introduce errors in existing code label Mar 22, 2023
@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, it looks like the DT test run failed. Please check the log for more details.
You can check the log here.

@jakebailey
Copy link
Member

@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Mar 22, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at aab1be6. You can monitor the build here.

Update: The results are in!

@ahejlsberg
Copy link
Member Author

ahejlsberg commented Mar 22, 2023

@jakebailey @RyanCavanaugh I think the new errors are better. They're caused by the change to use initialType in the calls to isTypeSubsetOf but aren't actually necessary to fix the original issue. Previously, the undefined we inject in the initial type to catch missing initialization situations was seen as a "foreign" type because it isn't part of the declared type. That would then cause us to perform subtype reduction, in which void would eat the undefined, leaving us with the declared type. That in turn would make it look like all code paths initialized the variable and we wouldn't report the error.

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, it looks like the DT test run failed. Please check the log for more details.
You can check the log here.

@fatcerberus
Copy link

fatcerberus commented Mar 22, 2023

To be fair, nobody should be declaring things as T | void anyway. void !== undefined. #42709 FTW 😉

@ahejlsberg ahejlsberg merged commit 511921e into main Mar 23, 2023
@ahejlsberg ahejlsberg deleted the fix53425 branch March 23, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team Breaking Change Would introduce errors in existing code 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.

if ('A' in el) {} causes code below to error
5 participants