Fix bug in type analysis for ComprehensionNodes.
authorCraig Citro <craigcitro@gmail.com>
Sat, 17 Jul 2010 07:16:50 +0000 (00:16 -0700)
committerCraig Citro <craigcitro@gmail.com>
Sat, 17 Jul 2010 07:16:50 +0000 (00:16 -0700)
Cython/Compiler/ExprNodes.py
tests/run/list_comprehension.pyx [new file with mode: 0644]

index 035f97e6c3ad5049f25b4d183579336701f8da12..09c925f191479cfbe6b270c480fe6b4ae75268d2 100755 (executable)
@@ -3988,6 +3988,9 @@ class ComprehensionNode(ScopedExprNode):
         if not self.has_local_scope:
             self.loop.analyse_expressions(env)
 
+    def analyse_expressions(self, env):
+        self.analyse_types(env)
+
     def analyse_scoped_expressions(self, env):
         if self.has_local_scope:
             self.loop.analyse_expressions(env)
diff --git a/tests/run/list_comprehension.pyx b/tests/run/list_comprehension.pyx
new file mode 100644 (file)
index 0000000..2360a71
--- /dev/null
@@ -0,0 +1,8 @@
+
+def foo():
+    """
+    >>> foo()
+    [[], [-1], [-1, 0], [-1, 0, 1]]
+    """
+    result = [[a-1 for a in range(b)] for b in range(4)]
+    return result