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 for crash on call expression with private identifiers. #42861

Conversation

dragomirtitian
Copy link
Contributor

@dragomirtitian dragomirtitian commented Feb 18, 2021

Fix for crash when using ca call expression on private identifier coming from an any typed variable.

Fixes #42860

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Feb 18, 2021
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.

I'll do a cherry pick as soon as we're ready to merge. Looks good to me though.

@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 Feb 18, 2021
@dragomirtitian dragomirtitian force-pushed the fix-call-expression-with-private-identifier-on-any branch from 5d2e57e to 21eb38b Compare February 18, 2021 20:53
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

This looks OK to me, my minor lament aside. @sandersn has a bit more context here though.

const prop = getPropertyOfType(type, isPrivateIdentifier(name) ? getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText) : name.escapedText);
let prop: Symbol | undefined;
if (isPrivateIdentifier(name)) {
if (!type.symbol) {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, I dislike relying on type.symbol, but it seems like we can only guarantee getNodeLinks((<PropertyAccessExpression>node).expression).resolvedSymbol exists for Identifier LHSs, since as getTypeOfDottedName recurs, it doesn't set it on other interesting LHS node kinds, like checkPropertyAccessExpressionOrQualifiedName sometimes does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially had an isAnyLike check since I discovered the issue on any, but never and unknown also trigger the issue.

@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-4.2

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 18, 2021

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-4.2 on this PR at 21eb38b. You can monitor the build here.

@DanielRosenwasser DanielRosenwasser merged commit a2ed469 into microsoft:master Feb 18, 2021
typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Feb 18, 2021
Component commits:
21eb38b Fix for crash when using ca call expression on private identifier coming from an any typed variable. (GH microsoft#42860)
@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I've opened #42867 for you.

DanielRosenwasser pushed a commit that referenced this pull request Feb 18, 2021
Component commits:
21eb38b Fix for crash when using ca call expression on private identifier coming from an any typed variable. (GH #42860)

Co-authored-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
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.

Regression: Compiler crash on call expression with private identifier on an any typed variable in 4.2RC
5 participants