-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fix for #1698 #1989
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
Fix for #1698 #1989
Changes from all commits
a34af88
b9291c4
317140b
2c71504
6b03983
74ba9c5
21ab34d
c70b0d2
ce80281
19d0920
9aa4799
e53c355
6026e66
8053579
b364cdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
Type, AnyType, NoneTyp, Void, TypeVisitor, Instance, UnboundType, | ||
ErrorType, TypeVarType, CallableType, TupleType, ErasedType, TypeList, | ||
UnionType, FunctionLike, Overloaded, PartialType, DeletedType, | ||
UninhabitedType, TypeType | ||
UninhabitedType, TypeType, true_or_false | ||
) | ||
from mypy.maptype import map_instance_to_supertype | ||
from mypy.subtypes import is_subtype, is_equivalent, is_subtype_ignoring_tvars | ||
|
@@ -17,6 +17,11 @@ | |
def join_simple(declaration: Type, s: Type, t: Type) -> Type: | ||
"""Return a simple least upper bound given the declared type.""" | ||
|
||
if (s.can_be_true, s.can_be_false) != (t.can_be_true, t.can_be_false): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need this for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to test and couldn't make a failing case with join_type; I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
# if types are restricted in different ways, use the more general versions | ||
s = true_or_false(s) | ||
t = true_or_false(t) | ||
|
||
if isinstance(s, AnyType): | ||
return s | ||
|
||
|
@@ -60,6 +65,11 @@ def join_types(s: Type, t: Type) -> Type: | |
|
||
If the join does not exist, return an ErrorType instance. | ||
""" | ||
if (s.can_be_true, s.can_be_false) != (t.can_be_true, t.can_be_false): | ||
# if types are restricted in different ways, use the more general versions | ||
s = true_or_false(s) | ||
t = true_or_false(t) | ||
|
||
if isinstance(s, AnyType): | ||
return s | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have an
assert False, "Unknown boolean operator"
instead of killing the else completely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding an assertion about e.op at the beginning (which is assured by
visit_op_expr
)