forked from M-Labs/artiq
1
0
Fork 0

Revert "Require boolean operand in BoolOp."

This reverts commit 5d518dcec6.
This commit is contained in:
whitequark 2015-07-22 18:35:18 +03:00
parent 51aef980a0
commit de181e0cb9
4 changed files with 14 additions and 9 deletions

View File

@ -305,7 +305,7 @@ class ASTTypedRewriter(algorithm.Transformer):
def visit_BoolOp(self, node): def visit_BoolOp(self, node):
node = self.generic_visit(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=node.op, values=node.values,
op_locs=node.op_locs, loc=node.loc) op_locs=node.op_locs, loc=node.loc)
return self.visit(node) return self.visit(node)

View File

@ -154,8 +154,8 @@ class Inferencer(algorithm.Visitor):
def visit_BoolOpT(self, node): def visit_BoolOpT(self, node):
self.generic_visit(node) self.generic_visit(node)
for value in node.values: for value in node.values:
self._unify(value.type, builtins.TBool(), self._unify(node.type, value.type,
value.loc, None) node.loc, value.loc, self._makenotes_elts(node.values, "an operand"))
def visit_UnaryOpT(self, node): def visit_UnaryOpT(self, node):
self.generic_visit(node) self.generic_visit(node)

View File

@ -14,6 +14,8 @@ a = b
# CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool # CHECK-L: ${LINE:+1}: error: cannot unify int(width='a) with bool
1 and False 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) # CHECK-L: ${LINE:+1}: error: expected unary '+' operand to be of numeric type, not list(elt='a)
+[] +[]

View File

@ -39,17 +39,20 @@ j += [1.0]
True and False True and False
# CHECK-L: True:bool and False:bool:bool # CHECK-L: True:bool and False:bool:bool
~1 1 and 0
# CHECK-L: ~1:int(width='g):int(width='g) # CHECK-L: 1:int(width='g) and 0:int(width='g):int(width='g)
not True ~1
# CHECK-L: not True:bool:bool # CHECK-L: 1:int(width='h):int(width='h)
not 1
# CHECK-L: 1:int(width='i):bool
[x for x in [1]] [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 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" k = "x"
# CHECK-L: k:str # CHECK-L: k:str