Use information from find_isinstance_check in short-circuit case too#1751
Closed
rwbarton wants to merge 1 commit intopython:masterfrom
Closed
Use information from find_isinstance_check in short-circuit case too#1751rwbarton wants to merge 1 commit intopython:masterfrom
rwbarton wants to merge 1 commit intopython:masterfrom
Conversation
Member
|
Probably @ddfisher should review? |
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) |
Collaborator
There was a problem hiding this comment.
Why do we have to recheck e.left?
Contributor
Author
There was a problem hiding this comment.
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.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1733.