Skip to content

Do not do any reduction (even if it contains any) to the union type when getting contextual type #28005

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 1 commit into from
Oct 20, 2018

Conversation

sheetalkamat
Copy link
Member

Fixes #27975
Thanks @weswigham for point to this.

removeSubtypes(typeSet);
break;
}
if (typeSet.length === 0) {
Copy link
Member

@weswigham weswigham Oct 20, 2018

Choose a reason for hiding this comment

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

Shouldn't this branch still be outside the new if (unionReduction !== UnionReduction.None) { check? We can't go making 0-element unions, after all~

Copy link
Member Author

Choose a reason for hiding this comment

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

If types = 0 then its never as done by getUnionTypeFromSortedList because we are adding all the types to typeset when there is no reduction (only removing duplicates)

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 guess so; only the never case can be triggered when there are no reductions going on, and getUnionTypeFromSortedList does have a check for exactly that, so I guess it's fine.

@sheetalkamat sheetalkamat merged commit 424fcdd into master Oct 20, 2018
@sheetalkamat sheetalkamat deleted the noReductionUnion branch October 20, 2018 00:33
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.

2 participants