diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index f6a4cee7f..649dfb540 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -146,8 +146,6 @@ class Inferencer(algorithm.Visitor): def visit_IfExpT(self, node): self.generic_visit(node) - self._unify(node.test.type, builtins.TBool(), - node.test.loc, None) self._unify(node.body.type, node.orelse.type, node.body.loc, node.orelse.loc) self._unify(node.type, node.body.type, @@ -794,11 +792,6 @@ class Inferencer(algorithm.Visitor): node.value = self._coerce_one(value_type, node.value, other_node=node.target) - def visit_If(self, node): - self.generic_visit(node) - self._unify(node.test.type, builtins.TBool(), - node.test.loc, None) - def visit_For(self, node): old_in_loop, self.in_loop = self.in_loop, True self.generic_visit(node) @@ -809,8 +802,6 @@ class Inferencer(algorithm.Visitor): old_in_loop, self.in_loop = self.in_loop, True self.generic_visit(node) self.in_loop = old_in_loop - self._unify(node.test.type, builtins.TBool(), - node.test.loc, None) def visit_Break(self, node): if not self.in_loop: diff --git a/lit-test/compiler/inferencer/error_unify.py b/lit-test/compiler/inferencer/error_unify.py index 374c2603c..e1886b8e8 100644 --- a/lit-test/compiler/inferencer/error_unify.py +++ b/lit-test/compiler/inferencer/error_unify.py @@ -23,12 +23,3 @@ a = b # CHECK-L: ${LINE:+1}: error: type int(width='a) does not have an attribute 'x' (1).x - -# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool -1 if 1 else 1 - -# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool -if 1: pass - -# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool -while 1: pass diff --git a/lit-test/compiler/inferencer/gcd.py b/lit-test/compiler/inferencer/gcd.py index 87bd42716..e2d4b4779 100644 --- a/lit-test/compiler/inferencer/gcd.py +++ b/lit-test/compiler/inferencer/gcd.py @@ -3,7 +3,7 @@ def _gcd(a, b): if a < 0: a = -a - while a > 0: + while a: c = a a = b % a b = c diff --git a/lit-test/compiler/inferencer/unify.py b/lit-test/compiler/inferencer/unify.py index 85db30cb4..72d3fdde9 100644 --- a/lit-test/compiler/inferencer/unify.py +++ b/lit-test/compiler/inferencer/unify.py @@ -33,8 +33,8 @@ j = [] j += [1.0] # CHECK-L: j:list(elt=float) -1 if c else 2 -# CHECK-L: 1:int(width='f) if c:bool else 2:int(width='f):int(width='f) +1 if a else 2 +# CHECK-L: 1:int(width='f) if a:int(width='a) else 2:int(width='f):int(width='f) True and False # CHECK-L: True:bool and False:bool:bool