Better error for ** on integer types.
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 5 Sep 2007 18:39:47 +0000 (11:39 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 5 Sep 2007 18:39:47 +0000 (11:39 -0700)
Cython/Compiler/ExprNodes.py

index 80b0845ed409a4145a72ec356b624c2c5cad9879..0dfa86338d83c2577b265618a4afe41ccf803a07 100644 (file)
@@ -2610,6 +2610,15 @@ class PowNode(NumBinopNode):
     def c_types_okay(self, type1, type2):
         return type1.is_float or type2.is_float
     
+    def type_error(self):
+        if not (self.operand1.type.is_error or self.operand2.type.is_error):
+            if self.operand1.type.is_int and self.operand2.type.is_int:
+                error(self.pos, "C has no integer powering, use python ints or floats instead '%s' (%s; %s)" %
+                    (self.operator, self.operand1.type, self.operand2.type))
+            else:
+                NumBinopNode.type_error(self)
+        self.type = PyrexTypes.error_type
+    
     def calculate_result_code(self):
         return "pow(%s, %s)" % (
             self.operand1.result_code, self.operand2.result_code)