Skip to content

Conversation

andrewbranch
Copy link
Member

Fixes #45376

@andrewbranch andrewbranch merged commit c5b1011 into microsoft:main Feb 8, 2022
@andrewbranch andrewbranch deleted the bug/45376 branch February 8, 2022 20:57
if (!links.writeType && links.deferralWriteConstituents) {
Debug.assertIsDefined(links.deferralParent);
Debug.assertIsDefined(links.deferralConstituents);
links.writeType = links.deferralParent.flags & TypeFlags.Union ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents);
Copy link

Choose a reason for hiding this comment

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

Shouldn't the write type of a union be resolved into an intersection type? Just like the way mentioned in #30769

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 you come up with a code example that doesn’t work the way you expect, feel free to file an issue.

Copy link

Choose a reason for hiding this comment

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

If you come up with a code example that doesn’t work the way you expect, feel free to file an issue.

Please have a look at the unsound behavior described in #50142. A comment indicates that it should be treated using the same rule of #30769.

I'm not quite sure but I guess it could have relation to this PR, where the write type of a union is not resolved into an intersection, but a union.

Choose a reason for hiding this comment

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

FWIW there’s a second complication in play in #50142: subtype reduction. Subtype reduction means that NullableProp | NonNullableProp is likely to be reduced to just the former, making #30769 a moot point.

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

Successfully merging this pull request may close these issues.

Union of variant setters uses getter type for assignment
6 participants