cleanup
authorStefan Behnel <scoder@users.berlios.de>
Sun, 14 Dec 2008 14:17:54 +0000 (15:17 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 14 Dec 2008 14:17:54 +0000 (15:17 +0100)
Cython/Compiler/Optimize.py

index d985ced0b9476312a6c95915d3579e033743b760..df97cd3ec11bc9349e871b62453ca06865d11479 100644 (file)
@@ -444,17 +444,24 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
         else:
             return node
         new_node.value = new_node.constant_result = node.constant_result
-        new_node = new_node.coerce_to(node.type, self.module_scope)
+        new_node = new_node.coerce_to(node.type, self.current_scope)
         return new_node
 
     # in the future, other nodes can have their own handler method here
     # that can replace them with a constant result node
     
     def visit_ModuleNode(self, node):
-        self.module_scope = node.scope
+        self.current_scope = node.scope
         self.visitchildren(node)
         return node
 
+    def visit_FuncDefNode(self, node):
+        old_scope = self.current_scope
+        self.current_scope = node.entry.scope
+        self.visitchildren(node)
+        self.current_scope = old_scope
+        return node
+
     def visit_Node(self, node):
         self.visitchildren(node)
         return node