compiler: Fix comparison of nested lists

This commit is contained in:
David Nadlinger 2019-03-31 02:14:53 +01:00
parent 8e225433a5
commit baf102dbb2
2 changed files with 10 additions and 2 deletions

View File

@ -1453,6 +1453,7 @@ class ARTIQIRGenerator(algorithm.Visitor):
lhs_elt = self.append(ir.GetElem(lhs, index_phi))
rhs_elt = self.append(ir.GetElem(rhs, index_phi))
body_result = self.polymorphic_compare_pair(op, lhs_elt, rhs_elt)
body_end = self.current_block
loop_body2 = self.add_block("compare.body2")
self.current_block = loop_body2
@ -1468,8 +1469,8 @@ class ARTIQIRGenerator(algorithm.Visitor):
phi.add_incoming(compare_length, head)
loop_head.append(ir.BranchIf(loop_cond, loop_body, tail))
phi.add_incoming(ir.Constant(True, builtins.TBool()), loop_head)
loop_body.append(ir.BranchIf(body_result, loop_body2, tail))
phi.add_incoming(body_result, loop_body)
body_end.append(ir.BranchIf(body_result, loop_body2, tail))
phi.add_incoming(body_result, body_end)
if isinstance(op, ast.NotEq):
result = self.append(ir.Select(phi,

View File

@ -7,3 +7,10 @@ assert (x, y) == (1, 2)
lst = [1, 2, 3]
assert [x*x for x in lst] == [1, 4, 9]
assert [0] == [0]
assert [0] != [1]
assert [[0]] == [[0]]
assert [[0]] != [[1]]
assert [[[0]]] == [[[0]]]
assert [[[0]]] != [[[1]]]