Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypyc/irbuild/ll_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ def compare_tuples(self, lhs: Value, rhs: Value, op: str, line: int = -1) -> Val
compare = self.binary_op(lhs_item, rhs_item, op, line)
# Cast to bool if necessary since most types uses comparison returning a object type
# See generic_ops.py for more information
if not is_bool_rprimitive(compare.type):
if not (is_bool_rprimitive(compare.type) or is_bit_rprimitive(compare.type)):
compare = self.primitive_op(bool_op, [compare], line)
if i < len(lhs.type.types) - 1:
branch = Branch(compare, early_stop, check_blocks[i + 1], Branch.BOOL)
Expand Down
23 changes: 23 additions & 0 deletions mypyc/test-data/irbuild-tuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,26 @@ L0:
r0 = CPySequence_Multiply(a, 4)
b = r0
return 1

[case testTupleFloatElementComparison]
def f(x: tuple[float], y: tuple[float]) -> bool:
return x == y

[out]
def f(x, y):
x, y :: tuple[float]
r0, r1 :: float
r2 :: bit
r3 :: bool
L0:
r0 = x[0]
r1 = y[0]
r2 = r0 == r1
if not r2 goto L1 else goto L2 :: bool
L1:
r3 = 0
goto L3
L2:
r3 = 1
L3:
return r3