Type check after (not before) operation on inplace assignment.
authorRobert Bradshaw <robertwb@math.washington.edu>
Tue, 11 Sep 2007 23:39:51 +0000 (16:39 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Tue, 11 Sep 2007 23:39:51 +0000 (16:39 -0700)
Cython/Compiler/Nodes.py

index ddbfdda0a7b1f4cbedd81f601e614a6189936705..0900676a658e4a04076f6ddd0a514aee923148a2 100644 (file)
@@ -1629,10 +1629,12 @@ class InPlaceAssignmentNode(AssignmentNode):
         
     def allocate_rhs_temps(self, env):
         import ExprNodes
-        if self.lhs.type.is_pyobject or self.rhs.type.is_pyobject:
+        if self.lhs.type.is_pyobject:
+            self.rhs = self.rhs.coerce_to_pyobject(env)
+        elif self.rhs.type.is_pyobject:
             self.rhs = self.rhs.coerce_to(self.lhs.type, env)
         if self.lhs.type.is_pyobject:
-             self.result = ExprNodes.PyTempNode(self.pos, env)
+             self.result = ExprNodes.PyTempNode(self.pos, env).coerce_to(self.lhs.type, env)
              self.result.allocate_temps(env)
 #        if use_temp:
 #            self.rhs = self.rhs.coerce_to_temp(env)
@@ -1662,6 +1664,7 @@ class InPlaceAssignmentNode(AssignmentNode):
                     self.dup.py_result(),
                     self.rhs.py_result(),
                     code.error_goto_if_null(self.result.py_result(), self.pos)))
+            self.result.generate_evaluation_code(code) # May be a type check...
             self.rhs.generate_disposal_code(code)
             self.dup.generate_disposal_code(code)
             self.lhs.generate_assignment_code(self.result, code)