disable some constant folding operations that can break code
authorStefan Behnel <scoder@users.berlios.de>
Mon, 6 Apr 2009 17:13:25 +0000 (19:13 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 6 Apr 2009 17:13:25 +0000 (19:13 +0200)
Cython/Compiler/ExprNodes.py

index 0b03f89404416d367cb2184d012d4da162beb2a0..94aaf8612c138a944c70343acd4f5359cc5f47d7 100644 (file)
@@ -877,7 +877,9 @@ class FloatNode(ConstNode):
     type = PyrexTypes.c_double_type
 
     def calculate_constant_result(self):
-        self.constant_result = float(self.value)
+        # calculating float values is usually not a good idea
+        #self.constant_result = float(self.value)
+        pass
 
     def compile_time_value(self, denv):
         return float(self.value)
@@ -3889,7 +3891,9 @@ class TypecastNode(NewTempExprNode):
         self.operand.check_const()
 
     def calculate_constant_result(self):
-        self.constant_result = self.operand.constant_result
+        # we usually do not know the result of a type cast at code
+        # generation time
+        pass
     
     def calculate_result_code(self):
         opnd = self.operand
@@ -4949,7 +4953,8 @@ class CoercionNode(NewTempExprNode):
             print("%s Coercing %s" % (self, self.arg))
 
     def calculate_constant_result(self):
-        self.constant_result = self.arg.constant_result
+        # constant folding can break type coercion, so this is disabled
+        pass
             
     def annotate(self, code):
         self.arg.annotate(code)