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 crash when creating a union signature from signatures that do and don’t have this types #31560

Merged
merged 1 commit into from May 24, 2019

Conversation

andrewbranch
Copy link
Member

Fixes #31485 but not #31547 since that would be a breaking change

const thisType = getUnionType(map(unionSignatures, sig => sig.thisParameter ? getTypeOfSymbol(sig.thisParameter) : anyType), UnionReduction.Subtype);
thisParameter = createSymbolWithType(signature.thisParameter!, thisType);
thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
Copy link
Member Author

Choose a reason for hiding this comment

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

It feels fairly arbitrary to just pick the first one of these as the source for the new transient symbol, but as far as I can tell it doesn't matter. I thought maybe it would cause an odd behavior for go-to-definition, but then I discovered that go-to-definition on union signatures is already arbitrarily limited to a single signature (#31559), and it doesn't seem to be affected by this change. I briefly experimented with doing a proper merge of every thisParameter symbol, but since I couldn't find any observable effect and go-to-definition on the call expression is already kinda broken, I opted not to use the extra memory and CPU cycles to perform a merge that you probably can't observe anyway. It might be worth revisiting this in #31547 or #31559.

@andrewbranch andrewbranch merged commit a06ab85 into microsoft:master May 24, 2019
@andrewbranch andrewbranch deleted the bug/31485 branch May 24, 2019 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash involving union of function types
2 participants