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

Handle Unions of collections in ValueEnumerator, recursively #1639

merged 1 commit into from Oct 7, 2019


Copy link

commented Oct 7, 2019

Fixes #1622.

If we're trying to unpack a union, store a ValueEnumerator per union item, then produce unions as items from each of the nested enumerators.

Note that since the unions are of types and are not values, we need to do some extra work to shift back and forth between types and instances where needed.


  • Replace the Next property with a method, since it has side effects.
  • Replace a comment I added in a previous PR with a new one explaining what's actually happening.
  • Use ImmutableArray in ValueEnumerator (the default works better).
.Which.Should().HaveType("Union[BaseException, None]");

.Which.Should().HaveType("Union[TracebackType, None]");

This comment has been minimized.

Copy link

jakebailey Oct 7, 2019

Author Member

It'd be nice some day to convert Union[X, None] to Optional[X], since that's the more readable choice, but this is correct for now.

@jakebailey jakebailey merged commit a1962c8 into microsoft:master Oct 7, 2019
1 check passed
1 check passed
license/cla All CLA requirements met.
@jakebailey jakebailey deleted the jakebailey:union-of-tuples branch Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.