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

Don't always infer unions for conditional expressions #5095

Merged
merged 2 commits into from May 24, 2018

Conversation

Projects
None yet
3 participants
@JukkaL
Copy link
Collaborator

JukkaL commented May 22, 2018

Use a join for type of a conditional expression unless the type context
is a union type.

A recent change (#5041) modified the type to always use a union, but this
caused many problems in internal Dropbox repos that we aren't ready to
fix yet.

Don't always infer unions for conditional expressions
Use a join for type of a conditional expression unless the type context
is a union type.

A recent change (#5041) modified the type to always use a union, but this
caused many problems in internal Dropbox repos that we aren't ready to
fix yet.
@gvanrossum
Copy link
Member

gvanrossum left a comment

Just a comma in a comment.

@@ -2357,7 +2357,14 @@ def visit_conditional_expr(self, e: ConditionalExpr) -> Type:
# branch's type.
else_type = self.analyze_cond_branch(else_map, e.else_expr, context=if_type)

res = UnionType.make_simplified_union([if_type, else_type])
# Only create a union type if the type context is a union to be mostly

This comment has been minimized.

@gvanrossum

gvanrossum May 22, 2018

Member

comma before "to be mostly"

@msullivan

This comment has been minimized.

Copy link
Collaborator

msullivan commented May 24, 2018

Merging this, though I'd like to revert it at some point.

@msullivan msullivan merged commit 94309a1 into master May 24, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@msullivan msullivan deleted the conditional-expr branch May 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.