Skip to content

fix(51521): Using a of property declared after an initializing constructor triggers an assertion failure in JS #51524

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
Jan 20, 2023

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #51521

@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Nov 14, 2022
jakebailey
jakebailey previously approved these changes Jan 20, 2023
Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Given this change is now restricted to the binder, should the changes to the checker be reverted?

FWIW I sent a fix for this that was completely different and probably worse (#52321), thinking #39704 was the issue for this.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

I feel odd about this change - not binding feels like the wrong thing. The attempt to do JS inference in the first place is the wrong thing.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 20, 2023

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 20, 2023

Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/143279/artifacts?artifactName=tgz&fileId=B54BE1A540768A22EEBAE0C1294C666A8C3117398A1057802D384A6FC74A1D6302&fileName=/typescript-5.0.0-insiders.20230120.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jan 20, 2023

In fact, I think this causes other issues. If you open the built playground, switch to a JS file, paste in the code, and request diagnostics, you will get the following stack trace.

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'flags')
    at checkVariableLikeDeclaration (tsWorker.js:68839:20)
    at checkPropertyDeclaration (tsWorker.js:67050:9)
    at checkSourceElementWorker (tsWorker.js:71357:20)
    at checkSourceElement (tsWorker.js:71322:11)
    at forEach (tsWorker.js:91:26)
    at checkClassDeclaration (tsWorker.js:70040:9)
    at checkSourceElementWorker (tsWorker.js:71495:20)
    at checkSourceElement (tsWorker.js:71322:11)
    at forEach (tsWorker.js:91:26)
    at checkSourceFileWorker (tsWorker.js:71680:11)
Fuller Stack
checkVariableLikeDeclaration (tsWorker.js:68839)
checkPropertyDeclaration (tsWorker.js:67050)
checkSourceElementWorker (tsWorker.js:71357)
checkSourceElement (tsWorker.js:71322)
forEach (tsWorker.js:91)
checkClassDeclaration (tsWorker.js:70040)
checkSourceElementWorker (tsWorker.js:71495)
checkSourceElement (tsWorker.js:71322)
forEach (tsWorker.js:91)
checkSourceFileWorker (tsWorker.js:71680)
checkSourceFile (tsWorker.js:71647)
checkSourceFileWithEagerDiagnostics (tsWorker.js:71741)
getDiagnosticsWorker (tsWorker.js:71749)
getDiagnostics2 (tsWorker.js:71726)
(anonymous) (tsWorker.js:97890)
runWithCancellationToken (tsWorker.js:97863)
getBindAndCheckDiagnosticsForFileNoCache (tsWorker.js:97878)
getAndCacheDiagnostics (tsWorker.js:98153)
getBindAndCheckDiagnosticsForFile (tsWorker.js:97875)
getSemanticDiagnosticsForFile (tsWorker.js:97872)
getDiagnosticsHelper (tsWorker.js:97811)
getSemanticDiagnostics (tsWorker.js:97824)
getSemanticDiagnostics (tsWorker.js:112356)
getSemanticDiagnostics (tsWorker.js:171771)

Can you make your test request errors as well?

@jakebailey
Copy link
Member

Hmm, maybe #52321 is better if not binding is not preferable? (Tomorrow I'll grab this test and see)

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Jan 20, 2023

A playground should be ready shortly to try out. If you get to this before Jake does, feel free to cherry-pick the commit.

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Rechecked this against the tsreplay for the babel example and it does pass. This fix seems to be the best one?

@a-tarasyuk
Copy link
Contributor Author

@jakebailey What is tsreplay?

@jakebailey
Copy link
Member

@jakebailey What is tsreplay?

See the expando here, for example: #52317 (comment)

@DanielRosenwasser
Copy link
Member

@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 20, 2023

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

Update: The results are in!

@DanielRosenwasser
Copy link
Member

@typescript-bot user test tsserver
@typescript-bot test tsserver top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 20, 2023

Heya @DanielRosenwasser, I've started to run the diff-based top-repos suite (tsserver) on this PR at 7cd7628. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 20, 2023

Heya @DanielRosenwasser, I've started to run the diff-based user code test suite (tsserver) on this PR at 7cd7628. You can monitor the build here.

Update: The results are in!

Copy link
Member

@DanielRosenwasser DanielRosenwasser left a comment

Choose a reason for hiding this comment

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

Approved pending reasonable perf and test results.

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..51524

Metric main 51524 Delta Best Worst
Angular - node (v16.17.1, x64)
Memory used 358,182k (± 0.01%) 358,230k (± 0.01%) +48k (+ 0.01%) 358,178k 358,297k
Parse Time 4.12s (± 0.42%) 4.11s (± 0.40%) -0.00s (- 0.11%) 4.09s 4.13s
Bind Time 1.24s (± 1.06%) 1.24s (± 0.64%) -0.00s (- 0.07%) 1.23s 1.25s
Check Time 9.50s (± 0.41%) 9.49s (± 0.37%) -0.01s (- 0.15%) 9.44s 9.53s
Emit Time 8.07s (± 0.56%) 8.05s (± 0.35%) -0.02s (- 0.23%) 8.01s 8.08s
Total Time 22.93s (± 0.40%) 22.89s (± 0.22%) -0.04s (- 0.15%) 22.82s 22.95s
Compiler-Unions - node (v16.17.1, x64)
Memory used 194,893k (± 0.72%) 194,263k (± 0.10%) -630k (- 0.32%) 193,971k 194,445k
Parse Time 1.80s (± 0.21%) 1.80s (± 0.70%) +0.00s (+ 0.22%) 1.79s 1.82s
Bind Time 0.84s (± 1.15%) 0.84s (± 0.65%) -0.00s (- 0.36%) 0.83s 0.85s
Check Time 10.37s (± 0.26%) 10.30s (± 0.80%) -0.07s (- 0.67%) 10.21s 10.42s
Emit Time 3.04s (± 0.98%) 3.16s (± 5.73%) +0.12s (+ 3.86%) 3.01s 3.42s
Total Time 16.06s (± 0.26%) 16.10s (± 1.01%) +0.04s (+ 0.25%) 15.91s 16.36s
Monaco - node (v16.17.1, x64)
Memory used 343,248k (± 0.01%) 343,248k (± 0.01%) +0k (+ 0.00%) 343,212k 343,269k
Parse Time 3.10s (± 1.09%) 3.11s (± 0.77%) +0.01s (+ 0.33%) 3.06s 3.12s
Bind Time 1.09s (± 0.74%) 1.09s (± 0.51%) -0.00s (- 0.10%) 1.09s 1.10s
Check Time 7.89s (± 0.28%) 7.88s (± 0.43%) -0.01s (- 0.14%) 7.83s 7.93s
Emit Time 4.55s (± 0.93%) 4.52s (± 0.36%) -0.04s (- 0.79%) 4.50s 4.54s
Total Time 16.63s (± 0.53%) 16.59s (± 0.26%) -0.04s (- 0.23%) 16.53s 16.65s
TFS - node (v16.17.1, x64)
Memory used 299,667k (± 0.01%) 299,653k (± 0.00%) -14k (- 0.00%) 299,634k 299,664k
Parse Time 2.45s (± 1.11%) 2.42s (± 0.92%) -0.02s (- 0.89%) 2.40s 2.45s
Bind Time 1.27s (± 0.48%) 1.27s (± 0.88%) +0.00s (+ 0.13%) 1.25s 1.28s
Check Time 7.47s (± 0.37%) 7.47s (± 0.28%) +0.01s (+ 0.11%) 7.45s 7.51s
Emit Time 4.23s (± 0.41%) 4.24s (± 0.88%) +0.01s (+ 0.29%) 4.19s 4.29s
Total Time 15.41s (± 0.29%) 15.41s (± 0.42%) -0.00s (- 0.01%) 15.30s 15.47s
material-ui - node (v16.17.1, x64)
Memory used 475,380k (± 0.00%) 475,353k (± 0.01%) -27k (- 0.01%) 475,303k 475,393k
Parse Time 3.62s (± 0.35%) 3.63s (± 0.54%) +0.01s (+ 0.34%) 3.60s 3.65s
Bind Time 1.00s (± 0.74%) 1.00s (± 0.55%) -0.00s (- 0.13%) 1.00s 1.01s
Check Time 17.96s (± 0.37%) 17.96s (± 0.39%) +0.00s (+ 0.01%) 17.90s 18.09s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 22.58s (± 0.31%) 22.59s (± 0.36%) +0.01s (+ 0.05%) 22.53s 22.74s
xstate - node (v16.17.1, x64)
Memory used 544,595k (± 0.03%) 544,527k (± 0.03%) -68k (- 0.01%) 544,373k 544,730k
Parse Time 4.58s (± 0.70%) 4.57s (± 0.35%) -0.01s (- 0.16%) 4.54s 4.58s
Bind Time 1.78s (± 0.23%) 1.78s (± 0.33%) -0.00s (- 0.05%) 1.77s 1.78s
Check Time 2.96s (± 0.52%) 2.94s (± 0.83%) -0.01s (- 0.48%) 2.91s 2.97s
Emit Time 0.09s (± 0.13%) 0.09s (± 0.27%) +0.00s (+ 0.13%) 0.09s 0.09s
Total Time 9.40s (± 0.47%) 9.38s (± 0.22%) -0.02s (- 0.26%) 9.35s 9.41s
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 51524 6
Baseline main 6

Developer Information:

Download Benchmark

@jakebailey
Copy link
Member

Perf looks good; merging.

@jakebailey jakebailey merged commit 1d81c1d into microsoft:main Jan 20, 2023
@typescript-bot
Copy link
Collaborator

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

Everything looks good!

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
Archived in project
Development

Successfully merging this pull request may close these issues.

Using a of property declared after an initializing constructor triggers an assertion failure in JS
6 participants