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

Fix debug assert in getConstructorDefinedThisAssignmentTypes #52321

Closed
wants to merge 2 commits into from

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Jan 20, 2023

Fixes #51521

It turns out the above has been lingering around for a while; this one shows up in the top100 tsserver traces somewhat often, i.e. #52317 (comment)

The requests all happen in babel's testing artifacts, which have the extension js but are in fact not JS. The one in the repro contains TypeScript code.

It seems like the bug is clear; this loop iterates over declarations to build an array of types, except that sometimes it can continue and skip over a declaration it doesn't like. But then, we pass that (smaller) array of types along with the original declaration array. The two need to be the same size as they are effectively zipped, but the loop explicitly doesn't guarantee that the two are going to be the same length. So, we can just build the list of declarations we actually cared about and then provide that instead.

But, I have absolutely no clue how to actually test this; it takes tsreplay 700 some requests to get the files into the right state for this to appear and I quite know how to reduce that when I can't reproduce it myself in the editor.

@jakebailey
Copy link
Member Author

Oh, huh. I think #51524 is for this exact bug, which is #51521.

@jakebailey
Copy link
Member Author

#51524 seems more correct to me.

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this

@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 a50fd5f. You can monitor the build here.

@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 a50fd5f. You can monitor the build here.

@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 a50fd5f. You can monitor the build here.

Co-authored-by: Oleksandr T <oleksandr.tarasiuk@outlook.com>
@jakebailey jakebailey reopened this Jan 20, 2023
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 20, 2023
@jakebailey
Copy link
Member Author

Pulled the other test (with with attribution)

@DanielRosenwasser
Copy link
Member

@typescript-bot pack this
@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 user code test suite (tsserver) on this PR at b3c27eb. 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 top-repos suite (tsserver) on this PR at b3c27eb. 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 tarball bundle task on this PR at b3c27eb. 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/143289/artifacts?artifactName=tgz&fileId=B3511640B1EB56CFD4274DC81E2470951F26377DAFEFECA1880B9BA6B45F6BA102&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/pr-build@5.0.0-pr-52321-12".;

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@DanielRosenwasser
Copy link
Member

I actually think this PR is not quite right either.

Why are we even trying to go down this path?

It really does feel like the right fix is to fix up the logic in setValueDeclaration - however, that function seems to be a very terse pile of jenga blocks. So maybe it's just a targeted fix in these cases.

You can check out #52323 to see my latest attempt.

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

palantir/blueprint

⚠️ Note that built also had errors ⚠️
Req #18401 - references
    at resolveNameHelper (/typescript-main/built/local/tsserver.js:48565:29)
    at resolveName (/typescript-main/built/local/tsserver.js:48563:12)
    at getResolvedSymbol (/typescript-main/built/local/tsserver.js:67770:54)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69885:20)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78046:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at checkPropertyAccessExpression (/typescript-main/built/local/tsserver.js:72567:162)
    at checkExpressionWorker (/typescript-main/built/local/tsserver.js:78080:16)
    at checkExpression (/typescript-main/built/local/tsserver.js:78000:32)
    at checkNonNullExpression (/typescript-main/built/local/tsserver.js:72488:29)
    at getEffectsSignature (/typescript-main/built/local/tsserver.js:68563:22)
    at getTypeAtFlowCall (/typescript-main/built/local/tsserver.js:68902:25)
    at getTypeAtFlowNode (/typescript-main/built/local/tsserver.js:68788:18)
    at getFlowTypeOfReference (/typescript-main/built/local/tsserver.js:68745:45)
    at checkIdentifier (/typescript-main/built/local/tsserver.js:69995:22)
Req #18401 - references
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69954:16)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at checkPropertyAccessExpression (/typescript-52321/built/local/tsserver.js:72569:162)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78082:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)
    at getEffectsSignature (/typescript-52321/built/local/tsserver.js:68565:22)
    at getTypeAtFlowCall (/typescript-52321/built/local/tsserver.js:68904:25)
    at getTypeAtFlowNode (/typescript-52321/built/local/tsserver.js:68790:18)
    at getFlowTypeOfReference (/typescript-52321/built/local/tsserver.js:68747:45)
    at checkIdentifier (/typescript-52321/built/local/tsserver.js:69997:22)
    at checkExpressionWorker (/typescript-52321/built/local/tsserver.js:78048:16)
    at checkExpression (/typescript-52321/built/local/tsserver.js:78002:32)
    at checkNonNullExpression (/typescript-52321/built/local/tsserver.js:72490:29)

That is a filtered view of the text. To see the raw error text, go to RepoResults4/palantir.blueprint.rawError.txt in the artifact folder

Last few requests

{"seq":18398,"type":"request","command":"definitionAndBoundSpan","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/2/docs-app.js","line":1,"offset":91533}}
{"seq":18399,"type":"request","command":"completionInfo","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/2/docs-app.js","line":1,"offset":91920,"includeExternalModuleExports":false,"includeInsertTextCompletions":true,"triggerKind":1}}
{"seq":18400,"type":"request","command":"completionEntryDetails","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/2/docs-app.js","line":1,"offset":91920,"entryNames":["_"]}}
{"seq":18401,"type":"request","command":"references","arguments":{"file":"@PROJECT_ROOT@/site/docs/versions/2/docs-app.js","line":1,"offset":92027}}

Repro Steps

  1. git clone https://github.com/palantir/blueprint --recurse-submodules
  2. In dir blueprint, run git reset --hard 0b74e8e5b02c6fd9017024a2b308424b67e4ea62
  3. Back in the initial folder, download RepoResults4/palantir.blueprint.replay.txt from the artifact folder
  4. npm install --no-save @typescript/server-replay
  5. npx tsreplay ./blueprint ./palantir.blueprint.replay.txt path/to/tsserver.js
  6. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

@jakebailey jakebailey closed this Jan 20, 2023
@jakebailey jakebailey deleted the fix-39704 branch January 20, 2023 18:17
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.

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