diff --git a/artiq/compiler/transforms/asttyped_rewriter.py b/artiq/compiler/transforms/asttyped_rewriter.py index 3adfde595..307033d1d 100644 --- a/artiq/compiler/transforms/asttyped_rewriter.py +++ b/artiq/compiler/transforms/asttyped_rewriter.py @@ -305,7 +305,7 @@ class ASTTypedRewriter(algorithm.Transformer): def visit_BoolOp(self, node): node = self.generic_visit(node) - node = asttyped.BoolOpT(type=builtins.TBool(), + node = asttyped.BoolOpT(type=types.TVar(), op=node.op, values=node.values, op_locs=node.op_locs, loc=node.loc) return self.visit(node) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 649dfb540..3422abf85 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -154,8 +154,8 @@ class Inferencer(algorithm.Visitor): def visit_BoolOpT(self, node): self.generic_visit(node) for value in node.values: - self._unify(value.type, builtins.TBool(), - value.loc, None) + self._unify(node.type, value.type, + node.loc, value.loc, self._makenotes_elts(node.values, "an operand")) def visit_UnaryOpT(self, node): self.generic_visit(node) diff --git a/lit-test/compiler/inferencer/error_unify.py b/lit-test/compiler/inferencer/error_unify.py index e1886b8e8..e81537d29 100644 --- a/lit-test/compiler/inferencer/error_unify.py +++ b/lit-test/compiler/inferencer/error_unify.py @@ -14,6 +14,8 @@ a = b # CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool 1 and False +# CHECK-L: note: an operand of type int(width='a) +# CHECK-L: note: an operand of type bool # CHECK-L: ${LINE:+1}: error: expected unary '+' operand to be of numeric type, not list(elt='a) +[] diff --git a/lit-test/compiler/inferencer/unify.py b/lit-test/compiler/inferencer/unify.py index 72d3fdde9..48681fdcb 100644 --- a/lit-test/compiler/inferencer/unify.py +++ b/lit-test/compiler/inferencer/unify.py @@ -39,17 +39,20 @@ j += [1.0] True and False # CHECK-L: True:bool and False:bool:bool -~1 -# CHECK-L: ~1:int(width='g):int(width='g) +1 and 0 +# CHECK-L: 1:int(width='g) and 0:int(width='g):int(width='g) -not True -# CHECK-L: not True:bool:bool +~1 +# CHECK-L: 1:int(width='h):int(width='h) + +not 1 +# CHECK-L: 1:int(width='i):bool [x for x in [1]] -# CHECK-L: [x:int(width='h) for x:int(width='h) in [1:int(width='h)]:list(elt=int(width='h))]:list(elt=int(width='h)) +# CHECK-L: [x:int(width='j) for x:int(width='j) in [1:int(width='j)]:list(elt=int(width='j))]:list(elt=int(width='j)) lambda x, y=1: x -# CHECK-L: lambda x:'i, y:int(width='j)=1:int(width='j): x:'i:(x:'i, ?y:int(width='j))->'i +# CHECK-L: lambda x:'k, y:int(width='l)=1:int(width='l): x:'k:(x:'k, ?y:int(width='l))->'k k = "x" # CHECK-L: k:str