Skip to content

Conversation

@rwbarton
Copy link
Contributor

Fixes #1733.

@gvanrossum
Copy link
Member

Probably @ddfisher should review?

@ddfisher
Copy link
Collaborator

I'll take a look tomorrow!

elif left_map is not None:
for var, type in left_map.items():
self.chk.binder.push(var, type)
left_type = self.accept(e.left, ctx)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we have to recheck e.left?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the tests includes an example where we learn more about the type of an expression when we find out it is true. isinstance(x, A) and x.a has type Union[bool, A] (where x.a : A) but isinstance(x, A) and x.a or A() has type A because for it to evaluate to isinstance(x, A) and x.a, that expression must be true and then it will evaluate to x.a.

In fact, that logic applies to any expression p and q or r even if p is not an isinstance check, so perhaps this isn't a very compelling example.

@ddfisher
Copy link
Collaborator

To the best of my understanding, this is superseded by #1989. The tests for this PR pass after #1989.

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.

3 participants