Skip to content

Improve uncalled function checks #41599

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 1 commit into from
Nov 30, 2020
Merged

Conversation

sandersn
Copy link
Member

Fixes #41586
Fixes #41588

  1. For binary expressions, if the immediate parent is an IfStatement, then check the body of the if statement. I didn't walk upward to find an IfStatement because in my experimentation I found that binary expression uncalled-function errors are only issued when the expression is on the left of the top-most binary expression.

  2. For property accesses with interspersed calls, I added a CallExpression case. In fact, any expression could appear here, but I only want to fix calls for now since that's all we've observed in Definitely Typed, and we didn't see anything else in the user tests or RWC tests. I also didn't examine parameters of the intermediate call expressions, but I don't think it's needed since the intent is to avoid false positives.

Fixes #41586
Fixes #41588

1. For binary expressions, if the immediate parent is an IfStatement,
then check the body of the if statement. I didn't walk upward to find an
IfStatement because in my experimentation I found that binary expression
uncalled-function errors are only issued when the expression is on the left of the
top-most binary expression.

2. For property accesses with interspersed calls, I added a
CallExpression case. In fact, any expression could appear here, but I
only want to fix calls for now since that's all we've observed in
Definitely Typed, and we didn't see anything else in the user tests or RWC
tests. I also didn't examine parameters of the intermediate call
expressions, but I don't think it's needed since the intent is to avoid
false positives.
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 19, 2020
@sandersn
Copy link
Member Author

@a-tarasyuk thanks for your help on this so far. If you can think of a test case that would require walking up multiple nodes to look for an IfStatement, please let me know.

}
// ok
if (chrome.platformKeys.subtleCrypto().exportKey) {
chrome.platformKeys.subtleCrypto().exportKey
Copy link
Member

Choose a reason for hiding this comment

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

I think I need more coffee; why is this ok?

Copy link
Member

@DanielRosenwasser DanielRosenwasser Nov 19, 2020

Choose a reason for hiding this comment

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

Because it's "used" in the body of the if, even if it's not called.

Copy link
Member Author

Choose a reason for hiding this comment

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

You just need a usage in the body. It doesn't actually have to call it.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this
@typescript-bot test this
@typescript-bot user test this
@typescript-bot run dt
@typescript-bot perf test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 19, 2020

Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 7265f49. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 19, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 19, 2020

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 19, 2020

Heya @DanielRosenwasser, I've started to run the parallelized community code test suite on this PR at 7265f49. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 19, 2020

Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 7265f49. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - master..41599

Metric master 41599 Delta Best Worst
Angular - node (v10.16.3, x64)
Memory used 344,481k (± 0.03%) 344,471k (± 0.02%) -9k (- 0.00%) 344,313k 344,656k
Parse Time 1.98s (± 0.34%) 1.99s (± 0.63%) +0.01s (+ 0.55%) 1.98s 2.04s
Bind Time 0.83s (± 0.85%) 0.83s (± 0.70%) -0.00s (- 0.24%) 0.81s 0.84s
Check Time 4.96s (± 0.51%) 4.96s (± 0.32%) -0.01s (- 0.14%) 4.93s 5.01s
Emit Time 5.36s (± 0.41%) 5.33s (± 0.50%) -0.03s (- 0.58%) 5.29s 5.41s
Total Time 13.13s (± 0.27%) 13.11s (± 0.31%) -0.03s (- 0.21%) 13.04s 13.21s
Monaco - node (v10.16.3, x64)
Memory used 354,697k (± 0.02%) 354,722k (± 0.02%) +25k (+ 0.01%) 354,539k 354,850k
Parse Time 1.59s (± 0.35%) 1.60s (± 0.48%) +0.01s (+ 0.44%) 1.58s 1.62s
Bind Time 0.72s (± 0.51%) 0.73s (± 0.50%) +0.00s (+ 0.14%) 0.72s 0.73s
Check Time 5.13s (± 0.75%) 5.18s (± 0.40%) +0.05s (+ 0.96%) 5.12s 5.21s
Emit Time 2.79s (± 0.56%) 2.80s (± 0.59%) +0.01s (+ 0.39%) 2.76s 2.84s
Total Time 10.24s (± 0.42%) 10.30s (± 0.30%) +0.07s (+ 0.66%) 10.21s 10.36s
TFS - node (v10.16.3, x64)
Memory used 307,817k (± 0.01%) 307,882k (± 0.02%) +65k (+ 0.02%) 307,785k 308,059k
Parse Time 1.24s (± 0.54%) 1.24s (± 0.66%) +0.00s (+ 0.00%) 1.22s 1.26s
Bind Time 0.68s (± 0.99%) 0.68s (± 0.76%) +0.00s (+ 0.59%) 0.67s 0.69s
Check Time 4.58s (± 0.58%) 4.58s (± 0.31%) -0.00s (- 0.02%) 4.54s 4.61s
Emit Time 2.96s (± 0.79%) 2.93s (± 1.26%) -0.03s (- 1.08%) 2.84s 3.00s
Total Time 9.46s (± 0.42%) 9.43s (± 0.42%) -0.03s (- 0.27%) 9.31s 9.49s
material-ui - node (v10.16.3, x64)
Memory used 489,342k (± 0.01%) 489,336k (± 0.01%) -6k (- 0.00%) 489,219k 489,407k
Parse Time 2.06s (± 0.53%) 2.05s (± 0.79%) -0.01s (- 0.44%) 2.03s 2.11s
Bind Time 0.65s (± 1.08%) 0.65s (± 0.89%) +0.00s (+ 0.15%) 0.64s 0.66s
Check Time 13.51s (± 0.77%) 13.65s (± 0.72%) +0.14s (+ 1.01%) 13.49s 13.87s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 16.22s (± 0.72%) 16.35s (± 0.60%) +0.13s (+ 0.78%) 16.19s 16.59s
Angular - node (v12.1.0, x64)
Memory used 322,207k (± 0.10%) 322,301k (± 0.02%) +95k (+ 0.03%) 322,148k 322,433k
Parse Time 1.96s (± 0.61%) 1.96s (± 0.55%) +0.00s (+ 0.05%) 1.93s 1.98s
Bind Time 0.81s (± 0.71%) 0.81s (± 0.45%) +0.00s (+ 0.12%) 0.81s 0.82s
Check Time 4.89s (± 0.73%) 4.87s (± 0.34%) -0.02s (- 0.41%) 4.84s 4.90s
Emit Time 5.49s (± 0.61%) 5.49s (± 0.73%) +0.01s (+ 0.13%) 5.41s 5.61s
Total Time 13.15s (± 0.51%) 13.13s (± 0.36%) -0.01s (- 0.11%) 13.04s 13.26s
Monaco - node (v12.1.0, x64)
Memory used 336,854k (± 0.02%) 336,864k (± 0.02%) +10k (+ 0.00%) 336,700k 337,075k
Parse Time 1.58s (± 0.59%) 1.58s (± 0.64%) +0.00s (+ 0.13%) 1.57s 1.61s
Bind Time 0.71s (± 0.52%) 0.71s (± 1.24%) +0.00s (+ 0.57%) 0.70s 0.74s
Check Time 4.91s (± 0.46%) 4.90s (± 0.31%) -0.01s (- 0.24%) 4.88s 4.95s
Emit Time 2.87s (± 0.45%) 2.86s (± 0.54%) -0.01s (- 0.38%) 2.82s 2.89s
Total Time 10.06s (± 0.25%) 10.05s (± 0.28%) -0.01s (- 0.13%) 10.00s 10.13s
TFS - node (v12.1.0, x64)
Memory used 292,056k (± 0.02%) 292,069k (± 0.02%) +13k (+ 0.00%) 291,920k 292,194k
Parse Time 1.25s (± 0.85%) 1.26s (± 1.21%) +0.00s (+ 0.24%) 1.23s 1.29s
Bind Time 0.65s (± 0.91%) 0.65s (± 0.69%) -0.01s (- 0.92%) 0.64s 0.66s
Check Time 4.52s (± 0.55%) 4.52s (± 0.46%) +0.00s (+ 0.04%) 4.48s 4.56s
Emit Time 2.96s (± 0.72%) 2.96s (± 0.72%) +0.01s (+ 0.17%) 2.93s 3.00s
Total Time 9.38s (± 0.39%) 9.39s (± 0.52%) +0.01s (+ 0.09%) 9.30s 9.48s
material-ui - node (v12.1.0, x64)
Memory used 467,342k (± 0.05%) 467,227k (± 0.07%) -115k (- 0.02%) 466,358k 467,546k
Parse Time 2.08s (± 0.51%) 2.08s (± 0.53%) +0.00s (+ 0.19%) 2.06s 2.11s
Bind Time 0.64s (± 0.74%) 0.64s (± 1.06%) +0.00s (+ 0.16%) 0.63s 0.66s
Check Time 12.04s (± 0.55%) 12.16s (± 1.25%) +0.12s (+ 1.01%) 11.94s 12.61s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.76s (± 0.47%) 14.89s (± 0.99%) +0.13s (+ 0.89%) 14.66s 15.33s
Angular - node (v8.9.0, x64)
Memory used 347,016k (± 0.03%) 347,012k (± 0.02%) -4k (- 0.00%) 346,880k 347,194k
Parse Time 2.51s (± 0.38%) 2.51s (± 0.50%) -0.00s (- 0.12%) 2.49s 2.54s
Bind Time 0.87s (± 0.60%) 0.87s (± 1.09%) +0.01s (+ 0.58%) 0.86s 0.90s
Check Time 5.62s (± 0.67%) 5.63s (± 0.66%) +0.01s (+ 0.27%) 5.57s 5.71s
Emit Time 6.33s (± 0.66%) 6.40s (± 1.57%) +0.06s (+ 1.03%) 6.11s 6.67s
Total Time 15.33s (± 0.31%) 15.42s (± 0.69%) +0.08s (+ 0.53%) 15.08s 15.60s
Monaco - node (v8.9.0, x64)
Memory used 358,548k (± 0.01%) 358,533k (± 0.02%) -15k (- 0.00%) 358,425k 358,713k
Parse Time 1.93s (± 0.46%) 1.93s (± 0.42%) -0.00s (- 0.05%) 1.92s 1.96s
Bind Time 0.91s (± 0.82%) 0.91s (± 0.68%) -0.00s (- 0.11%) 0.90s 0.93s
Check Time 5.66s (± 0.45%) 5.66s (± 0.57%) +0.00s (+ 0.05%) 5.60s 5.75s
Emit Time 3.41s (± 0.70%) 3.42s (± 0.50%) +0.00s (+ 0.09%) 3.39s 3.45s
Total Time 11.92s (± 0.36%) 11.92s (± 0.39%) +0.00s (+ 0.03%) 11.84s 12.03s
TFS - node (v8.9.0, x64)
Memory used 310,368k (± 0.02%) 310,397k (± 0.02%) +29k (+ 0.01%) 310,297k 310,486k
Parse Time 1.57s (± 0.58%) 1.57s (± 0.38%) -0.01s (- 0.38%) 1.55s 1.58s
Bind Time 0.68s (± 0.87%) 0.68s (± 0.65%) -0.00s (- 0.44%) 0.67s 0.69s
Check Time 5.29s (± 0.31%) 5.33s (± 0.63%) +0.04s (+ 0.76%) 5.28s 5.42s
Emit Time 2.96s (± 0.83%) 2.97s (± 1.15%) +0.02s (+ 0.58%) 2.90s 3.05s
Total Time 10.50s (± 0.34%) 10.55s (± 0.52%) +0.05s (+ 0.47%) 10.43s 10.69s
material-ui - node (v8.9.0, x64)
Memory used 496,284k (± 0.01%) 496,355k (± 0.01%) +71k (+ 0.01%) 496,262k 496,414k
Parse Time 2.49s (± 0.23%) 2.49s (± 0.56%) +0.00s (+ 0.16%) 2.45s 2.51s
Bind Time 0.81s (± 1.50%) 0.81s (± 1.19%) +0.01s (+ 0.75%) 0.79s 0.83s
Check Time 18.01s (± 0.70%) 17.99s (± 0.83%) -0.02s (- 0.09%) 17.60s 18.32s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 21.30s (± 0.58%) 21.29s (± 0.69%) -0.01s (- 0.03%) 20.94s 21.61s
Angular - node (v8.9.0, x86)
Memory used 198,979k (± 0.03%) 198,993k (± 0.02%) +14k (+ 0.01%) 198,884k 199,081k
Parse Time 2.42s (± 0.55%) 2.43s (± 0.86%) +0.01s (+ 0.46%) 2.39s 2.48s
Bind Time 1.02s (± 1.09%) 1.01s (± 0.59%) -0.01s (- 0.88%) 1.00s 1.03s
Check Time 5.05s (± 0.80%) 5.04s (± 0.47%) -0.02s (- 0.36%) 4.99s 5.10s
Emit Time 6.15s (± 1.18%) 6.10s (± 0.84%) -0.05s (- 0.81%) 5.93s 6.20s
Total Time 14.65s (± 0.57%) 14.58s (± 0.31%) -0.07s (- 0.48%) 14.48s 14.66s
Monaco - node (v8.9.0, x86)
Memory used 203,066k (± 0.03%) 203,049k (± 0.02%) -17k (- 0.01%) 202,974k 203,170k
Parse Time 1.97s (± 0.91%) 1.98s (± 0.81%) +0.01s (+ 0.51%) 1.95s 2.03s
Bind Time 0.71s (± 0.83%) 0.72s (± 0.81%) +0.00s (+ 0.42%) 0.71s 0.73s
Check Time 5.72s (± 1.61%) 5.78s (± 0.53%) +0.06s (+ 1.10%) 5.71s 5.84s
Emit Time 2.82s (± 4.23%) 2.75s (± 0.70%) -0.06s (- 2.17%) 2.71s 2.80s
Total Time 11.22s (± 0.29%) 11.24s (± 0.40%) +0.01s (+ 0.13%) 11.12s 11.33s
TFS - node (v8.9.0, x86)
Memory used 177,473k (± 0.03%) 177,528k (± 0.03%) +55k (+ 0.03%) 177,435k 177,613k
Parse Time 1.62s (± 0.65%) 1.61s (± 1.54%) -0.01s (- 0.31%) 1.58s 1.69s
Bind Time 0.66s (± 0.88%) 0.65s (± 0.80%) -0.01s (- 0.91%) 0.64s 0.66s
Check Time 4.86s (± 0.32%) 4.86s (± 0.32%) 0.00s ( 0.00%) 4.83s 4.90s
Emit Time 2.87s (± 0.84%) 2.85s (± 1.50%) -0.01s (- 0.49%) 2.76s 2.95s
Total Time 10.00s (± 0.33%) 9.97s (± 0.45%) -0.03s (- 0.25%) 9.87s 10.06s
material-ui - node (v8.9.0, x86)
Memory used 279,407k (± 0.02%) 279,419k (± 0.02%) +12k (+ 0.00%) 279,297k 279,491k
Parse Time 2.54s (± 0.67%) 2.55s (± 0.65%) +0.01s (+ 0.28%) 2.51s 2.58s
Bind Time 0.78s (± 6.34%) 0.80s (± 5.64%) +0.02s (+ 2.55%) 0.70s 0.88s
Check Time 16.47s (± 0.92%) 16.40s (± 0.86%) -0.07s (- 0.41%) 16.12s 16.69s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 19.79s (± 0.71%) 19.75s (± 0.77%) -0.04s (- 0.21%) 19.50s 20.07s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-166-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v10.16.3, x64)
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
Scenarios
  • Angular - node (v10.16.3, x64)
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Monaco - node (v10.16.3, x64)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • TFS - node (v10.16.3, x64)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • material-ui - node (v10.16.3, x64)
  • material-ui - node (v12.1.0, x64)
  • material-ui - node (v8.9.0, x64)
  • material-ui - node (v8.9.0, x86)
Benchmark Name Iterations
Current 41599 10
Baseline master 10

@typescript-bot
Copy link
Collaborator

The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master.

@sandersn sandersn merged commit 06fb724 into master Nov 30, 2020
@sandersn sandersn deleted the improve-uncalled-function-checks branch November 30, 2020 22:27
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Uncalled-function check misses usage of complex property access Uncalled-function error with function check in binary expression misses usage in body
4 participants