From: Stefan Behnel Date: Tue, 23 Nov 2010 19:03:45 +0000 (+0100) Subject: fix constant folding for nonsense code like '-False' X-Git-Tag: 0.14.alpha0~95 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=343f97968658842faf323fec2fe615642858b48c;p=cython.git fix constant folding for nonsense code like '-False' --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 62d29e31..c8abd0d4 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -2979,6 +2979,11 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): # this is a safe operation return ExprNodes.FloatNode(node.pos, value = '-' + node.operand.value, constant_result = node.constant_result) + if isinstance(node.operand, ExprNodes.BoolNode): + # not important at all, but simplifies the code below + return ExprNodes.IntNode(node.pos, value = str(node.constant_result), + type = PyrexTypes.c_int_type, + constant_result = node.constant_result) node_type = node.operand.type if node_type.is_int and node_type.signed or \ isinstance(node.operand, ExprNodes.IntNode) and node_type.is_pyobject: