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

[WIP] Support condition always true in prefix unary expression #60068

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tjenkinson
Copy link
Contributor

Opening as draft for now so we can run the extended tests and see how much breakage there is. See #46140 (comment)

cc @gabritto

Fixes #46140

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Sep 26, 2024
@tjenkinson tjenkinson changed the title Support condition always true in prefix unary expression [WIP] Support condition always true in prefix unary expression Sep 26, 2024
@gabritto
Copy link
Member

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 26, 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 @gabritto, the results of running the DT tests are ready.

There were interesting changes:

Branch only errors:

Package: js-fixtures
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/js-fixtures/js-fixtures-tests.ts
  16:10  error  TypeScript@local compile error: 
This condition will always return true since this function is always defined. Did you mean to call it instead?  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: xdate
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/xdate/xdate-tests.ts
  1177:18  error  TypeScript@local compile error: 
This condition will always return true since this function is always defined. Did you mean to call it instead?  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: activex-excel
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/activex-excel/activex-excel-tests.ts
  98:10  error  TypeScript@local compile error: 
This condition will always return true since this function is always defined. Did you mean to call it instead?  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: morgan
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/morgan/morgan-tests.ts
  88:10  error  TypeScript@local compile error: 
This condition will always return true since this function is always defined. Did you mean to call it instead?  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: yandex-maps
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/yandex-maps/yandex-maps-tests.ts
  162:10  error  TypeScript@local compile error: 
This condition will always return true since this function is always defined. Did you mean to call it instead?  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: bluebird
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/bluebird/bluebird-tests.ts
  827:11  error  TypeScript@local compile error: 
This condition will always return true since this 'import("/mnt/vss/_work/1/DefinitelyTyped/types/bluebird/index")<Foo>' is always defined  @definitelytyped/expect
  848:11  error  TypeScript@local compile error: 
This condition will always return true since this 'import("/mnt/vss/_work/1/DefinitelyTyped/types/bluebird/index")<Foo>' is always defined  @definitelytyped/expect

✖ 2 problems (2 errors, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.23_typescript@5.7.0-dev.20240926/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

You can check the log here.

@typescript-bot
Copy link
Collaborator

@gabritto Here are the results of running the user tests with tsc comparing main and refs/pull/60068/merge:

Something interesting changed - please have a look.

Details

lodash

/mnt/ts_downloads/_/m/lodash/tsconfig.json

  • [NEW] error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
    • /mnt/ts_downloads/_/m/lodash/node_modules/lodash/_getSymbols.js(20,19)
    • /mnt/ts_downloads/_/m/lodash/node_modules/lodash/_getSymbolsIn.js(16,21)

pyright

/mnt/ts_downloads/_/m/pyright/build.sh

  • [NEW] error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?
    • /mnt/ts_downloads/_/m/pyright/pyright: ../pyright-internal/src/common/memUtils.ts(39,10)
    • /mnt/ts_downloads/_/m/pyright/pyright-internal: src/common/memUtils.ts(39,10)
    • /mnt/ts_downloads/_/m/pyright/vscode-pyright: ../pyright-internal/src/common/memUtils.ts(39,10)

webpack

tsconfig.types.json

xterm.js

src/tsconfig-library-base.json

@typescript-bot
Copy link
Collaborator

@gabritto
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,340 62,340 ~ ~ ~ p=1.000 n=6
Types 50,378 50,378 ~ ~ ~ p=1.000 n=6
Memory used 193,305k (± 0.75%) 193,310k (± 0.75%) ~ 192,690k 196,283k p=1.000 n=6
Parse Time 1.31s (± 0.64%) 1.30s (± 0.94%) ~ 1.29s 1.32s p=0.928 n=6
Bind Time 0.71s 0.71s ~ ~ ~ p=1.000 n=6
Check Time 9.54s (± 0.14%) 9.54s (± 0.39%) ~ 9.49s 9.58s p=0.683 n=6
Emit Time 2.71s (± 0.38%) 2.69s (± 1.96%) ~ 2.62s 2.76s p=0.213 n=6
Total Time 14.27s (± 0.15%) 14.25s (± 0.40%) ~ 14.20s 14.36s p=0.092 n=6
angular-1 - node (v18.15.0, x64)
Errors 7 18 🔻+11 (+157.14%) ~ ~ p=0.001 n=6
Symbols 947,102 947,114 +12 (+ 0.00%) ~ ~ p=0.001 n=6
Types 410,738 410,747 +9 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 1,224,036k (± 0.01%) 1,223,972k (± 0.01%) ~ 1,223,891k 1,224,044k p=0.128 n=6
Parse Time 6.60s (± 0.43%) 6.64s (± 0.91%) ~ 6.55s 6.73s p=0.227 n=6
Bind Time 1.86s (± 0.59%) 1.87s (± 0.40%) ~ 1.86s 1.88s p=0.062 n=6
Check Time 31.28s (± 0.49%) 31.39s (± 0.35%) ~ 31.24s 31.54s p=0.199 n=6
Emit Time 15.07s (± 0.64%) 15.02s (± 0.18%) ~ 14.98s 15.05s p=0.226 n=6
Total Time 54.81s (± 0.44%) 54.91s (± 0.23%) ~ 54.75s 55.05s p=0.378 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,521,651 2,521,651 ~ ~ ~ p=1.000 n=6
Types 936,037 936,038 +1 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 2,351,721k (± 0.00%) 2,351,798k (± 0.00%) +78k (+ 0.00%) 2,351,728k 2,351,860k p=0.031 n=6
Parse Time 9.28s (± 0.23%) 9.28s (± 0.28%) ~ 9.25s 9.31s p=0.684 n=6
Bind Time 2.13s (± 0.48%) 2.13s (± 0.35%) ~ 2.12s 2.14s p=0.931 n=6
Check Time 73.53s (± 0.53%) 73.43s (± 0.54%) ~ 72.96s 74.02s p=0.575 n=6
Emit Time 0.27s (± 2.98%) 0.28s (± 1.47%) ~ 0.27s 0.28s p=0.248 n=6
Total Time 85.22s (± 0.43%) 85.12s (± 0.46%) ~ 84.64s 85.65s p=0.689 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 12 🔻+12 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 1,250,125 1,433,231 🔻+183,106 (+14.65%) ~ ~ p=0.001 n=6
Types 264,990 265,160 +170 (+ 0.06%) ~ ~ p=0.001 n=6
Memory used 2,404,629k (± 0.02%) 2,998,491k (± 0.01%) 🔻+593,863k (+24.70%) 2,998,083k 2,999,047k p=0.005 n=6
Parse Time 5.15s (± 0.86%) 8.61s (± 0.55%) 🔻+3.46s (+67.25%) 8.52s 8.65s p=0.005 n=6
Bind Time 1.90s (± 0.61%) 3.19s (± 0.58%) 🔻+1.29s (+67.92%) 3.18s 3.23s p=0.005 n=6
Check Time 34.89s (± 0.28%) 34.75s (± 0.67%) ~ 34.42s 35.13s p=0.108 n=6
Emit Time 3.02s (± 0.80%) 2.98s (± 1.57%) ~ 2.93s 3.04s p=0.336 n=6
Total Time 44.96s (± 0.26%) 49.55s (± 0.54%) 🔻+4.59s (+10.20%) 49.19s 49.96s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 12 🔻+12 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 1,250,125 1,433,231 🔻+183,106 (+14.65%) ~ ~ p=0.001 n=6
Types 264,990 265,160 +170 (+ 0.06%) ~ ~ p=0.001 n=6
Memory used 2,479,585k (± 0.02%) 3,078,730k (± 0.01%) 🔻+599,145k (+24.16%) 3,078,141k 3,079,257k p=0.005 n=6
Parse Time 6.32s (± 0.67%) 10.59s (± 0.77%) 🔻+4.26s (+67.45%) 10.50s 10.73s p=0.005 n=6
Bind Time 2.04s (± 0.40%) 3.61s (± 0.33%) 🔻+1.58s (+77.41%) 3.60s 3.63s p=0.005 n=6
Check Time 41.67s (± 0.89%) 41.56s (± 0.45%) ~ 41.28s 41.73s p=0.689 n=6
Emit Time 3.66s (± 3.76%) 3.60s (± 2.34%) ~ 3.49s 3.73s p=0.518 n=6
Total Time 53.73s (± 0.41%) 59.37s (± 0.23%) 🔻+5.64s (+10.50%) 59.15s 59.50s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 4 🔻+4 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 260,972 260,974 +2 (+ 0.00%) ~ ~ p=0.001 n=6
Types 106,405 106,405 ~ ~ ~ p=1.000 n=6
Memory used 436,765k (± 0.03%) 436,903k (± 0.04%) ~ 436,670k 437,163k p=0.128 n=6
Parse Time 3.44s (± 0.91%) 3.43s (± 0.63%) ~ 3.42s 3.47s p=0.462 n=6
Bind Time 1.30s (± 0.49%) 1.30s (± 0.31%) ~ 1.30s 1.31s p=0.673 n=6
Check Time 18.22s (± 0.54%) 18.18s (± 0.28%) ~ 18.12s 18.23s p=0.872 n=6
Emit Time 1.52s (± 1.13%) 1.52s (± 1.88%) ~ 1.49s 1.55s p=1.000 n=6
Total Time 24.48s (± 0.44%) 24.44s (± 0.28%) ~ 24.35s 24.52s p=0.630 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 68 75 🔻+7 (+10.29%) ~ ~ p=0.001 n=6
Symbols 225,916 225,916 ~ ~ ~ p=1.000 n=6
Types 94,414 94,417 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 370,943k (± 0.02%) 370,885k (± 0.01%) ~ 370,832k 370,940k p=0.093 n=6
Parse Time 3.45s (± 0.89%) 3.46s (± 0.94%) ~ 3.43s 3.50s p=0.462 n=6
Bind Time 1.93s (± 1.11%) 1.93s (± 1.48%) ~ 1.89s 1.96s p=0.871 n=6
Check Time 19.51s (± 0.50%) 19.61s (± 0.52%) ~ 19.51s 19.77s p=0.109 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.89s (± 0.50%) 25.00s (± 0.40%) ~ 24.90s 25.15s p=0.173 n=6
vscode - node (v18.15.0, x64)
Errors 1 16 🔻+15 (+1,500.00%) ~ ~ p=0.001 n=6
Symbols 3,104,470 3,104,541 +71 (+ 0.00%) ~ ~ p=0.001 n=6
Types 1,070,027 1,070,068 +41 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 3,199,724k (± 0.00%) 3,199,708k (± 0.01%) ~ 3,198,988k 3,199,959k p=0.298 n=6
Parse Time 13.94s (± 0.12%) 13.98s (± 0.33%) ~ 13.92s 14.06s p=0.053 n=6
Bind Time 4.45s (± 2.20%) 4.44s (± 2.77%) ~ 4.34s 4.60s p=0.872 n=6
Check Time 82.47s (± 0.28%) 82.89s (± 0.31%) +0.41s (+ 0.50%) 82.62s 83.25s p=0.020 n=6
Emit Time 22.41s (± 0.63%) 23.18s (± 5.23%) ~ 22.31s 25.10s p=0.687 n=6
Total Time 123.26s (± 0.24%) 124.48s (± 0.92%) +1.22s (+ 0.99%) 123.28s 126.04s p=0.020 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 278,997 278,997 ~ ~ ~ p=1.000 n=6
Types 113,861 113,861 ~ ~ ~ p=1.000 n=6
Memory used 428,555k (± 0.03%) 428,626k (± 0.03%) ~ 428,445k 428,729k p=0.298 n=6
Parse Time 4.91s (± 0.44%) 4.88s (± 0.69%) ~ 4.84s 4.93s p=0.260 n=6
Bind Time 2.12s (± 0.97%) 2.13s (± 1.22%) ~ 2.09s 2.17s p=0.465 n=6
Check Time 21.94s (± 0.54%) 21.91s (± 0.34%) ~ 21.84s 22.04s p=0.689 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.97s (± 0.38%) 28.93s (± 0.27%) ~ 28.82s 29.02s p=0.748 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 1 🔻+1 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 540,027 540,027 ~ ~ ~ p=1.000 n=6
Types 181,292 181,292 ~ ~ ~ p=1.000 n=6
Memory used 483,616k (± 0.01%) 483,642k (± 0.01%) ~ 483,583k 483,711k p=0.575 n=6
Parse Time 4.00s (± 0.41%) 4.01s (± 0.26%) ~ 4.00s 4.03s p=0.288 n=6
Bind Time 1.43s (± 0.72%) 1.44s (± 0.57%) ~ 1.43s 1.45s p=0.121 n=6
Check Time 22.90s (± 0.35%) 22.89s (± 0.21%) ~ 22.81s 22.95s p=0.748 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 28.33s (± 0.28%) 28.34s (± 0.17%) ~ 28.27s 28.41s p=0.747 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

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

Something interesting changed - please have a look.

Details

adobe/react-spectrum

9 of 15 projects failed to build with the old tsc and were ignored

packages/dev/codemods/tsconfig.json

apollographql/apollo-client

2 of 12 projects failed to build with the old tsc and were ignored

tsconfig.json

baidu/amis

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

packages/amis-formula/tsconfig-for-declaration.json

blakeblackshear/frigate

web/tsconfig.json

cheeriojs/cheerio

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.typedoc.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

date-fns/date-fns

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

tsconfig.lib.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

desktop/desktop

1 of 5 projects failed to build with the old tsc and were ignored

tsconfig.json

ether/etherpad-lite

src/tsconfig.json

FuelLabs/fuels-ts

34 of 58 projects failed to build with the old tsc and were ignored

packages/crypto/tsconfig.dts.json

gitpod-io/gitpod

12 of 20 projects failed to build with the old tsc and were ignored

components/gitpod-db/tsconfig.json

google/blockly

2 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

immich-app/immich

3 of 7 projects failed to build with the old tsc and were ignored

server/tsconfig.build.json

jupyterlab/jupyterlab

46 of 59 projects failed to build with the old tsc and were ignored

examples/filebrowser/src/tsconfig.json

konvajs/konva

tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

microsoft/vscode

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

src/tsconfig.tsec.json

src/tsconfig.monaco.json

src/tsconfig.json

extensions/html-language-features/server/tsconfig.json

extensions/gulp/tsconfig.json

extensions/emmet/tsconfig.json

extensions/css-language-features/server/tsconfig.json

  • error TS2801: This condition will always return true since this 'Thenable<import("/mnt/ts_downloads/_/m/vscode/extensions/css-language-features/server/node_modules/vscode-css-languageservice/lib/umd/cssLanguageTypes").LanguageSettings | undefined>' is always defined.

openai-translator/openai-translator

tsconfig.json

reduxjs/react-redux

1 of 3 projects failed to build with the old tsc and were ignored

tsconfig.json

tsconfig.build.json

reduxjs/redux-devtools

25 of 58 projects failed to build with the old tsc and were ignored

packages/d3-state-visualizer/tsconfig.json

extension/tsconfig.json

signalapp/Signal-Desktop

1 of 2 projects failed to build with the old tsc and were ignored

sticker-creator/tsconfig.json

tinacms/tinacms

13 of 25 projects failed to build with the old tsc and were ignored

packages/@tinacms/mdx/tsconfig.json

tusen-ai/naive-ui

3 of 6 projects failed to build with the old tsc and were ignored

src/tsconfig.demo.json

vercel/swr

6 of 8 projects failed to build with the old tsc and were ignored

tsconfig.json

  • error TS2774: This condition will always return true since this function is always defined. Did you mean to call it instead?

video-dev/hls.js

tsconfig.json

@gabritto
Copy link
Member

As I suspected, there are a lot of new errors in our extended tests.

I looked at a few of the new errors for uncalled functions, and there it seems that indeed, to support erroring on negated function conditions, we'd have to do the analysis of whether the function is called outside the if block, similar to what we do currently for non-negated function conditions to avoid false errors. I still have to look at the rest of the new function errors.

For the new promise errors, apollographql/apollo-client error looks like an error that is caused by an incorrect non-null assertion, so the new error is fine and could be fixed by them getting rid of the non-null assertion. For the blakeblackshear/frigate error, it looks like a bad new error because the promise is awaited and possibly we'd have to do a similar analysis of "is this promise awaited afterwards?". In vscode, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/src/vs/base/node/id.ts#L82, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts#L526, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/src/vs/workbench/services/search/common/search.ts#L819, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/extensions/html-language-features/server/src/htmlServer.ts#L121, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/extensions/emmet/src/test/abbreviationAction.test.ts#L223 are false errors, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/src/vs/workbench/browser/layout.ts#L1759 is maybe a good error, https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/extensions/gulp/src/main.ts#L184 is a good error.
https://github.com/video-dev/hls.js/blob/5cfbc0a0ce5587fa2a49b607d1e95861b20ac5cb/tests/unit/controller/eme-controller.ts#L228 I don't even know how to interpret, and https://github.com/video-dev/hls.js/blob/5cfbc0a0ce5587fa2a49b607d1e95861b20ac5cb/tests/unit/controller/eme-controller.ts#L447 is a false error that I'm not even sure how we could avoid...

For desktop/desktop, gitpod-io/gitpod, the new errors are good and I think they all indicate bugs.

@gabritto
Copy link
Member

@tjenkinson I think both the function and promise cases will require some extra work for avoiding most of the false errors. Let me know if you'd still like to keep working on it, I think it's a very good feature since we had at least 3 bugs detected in the extended tests.

@tjenkinson
Copy link
Contributor Author

tjenkinson commented Sep 27, 2024

hey @gabritto thanks for looking through them super promising it found some actual issues.

Do you think we'll need to handle cases like this one where the usage happens later and is not part of the if/else block? Or would just checking the if/else block be good enough?

Happy to continue digging but I think that will be a bit more complex looking at how things are structured at the moment as block can't just be the if/else body. It would need to traverse up to the containing block, find the if/else, and then look in all items below it?

@tjenkinson
Copy link
Contributor Author

Actually maybe this is a different kind of check.

If there's an if (!a), it needs to be ignored if:

  1. inside the if block something is assigned to a
  2. there's an else that uses a

I'm not sure if (2) will happen much in the wild so maybe the 1st will be enough

@tjenkinson
Copy link
Contributor Author

Also not sure https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/extensions/emmet/src/test/abbreviationAction.test.ts#L223 is a false error? Looking at the types expandPromise should always be defined so that check looks redundant?

@gabritto
Copy link
Member

gabritto commented Oct 4, 2024

Also not sure https://github.com/microsoft/vscode/blob/f71675cbd9ba6aef444321cbe5faf8dd81340e3b/extensions/emmet/src/test/abbreviationAction.test.ts#L223 is a false error? Looking at the types expandPromise should always be defined so that check looks redundant?

I think you are right in this case. However, I think we should still support that case to avoid false errors in code written in a similar way.

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.

Inverted Promise should warn like it does without inverting
3 participants