From e31d6a8635b2f1d0493fa6185354ece654cd4b65 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Sat, 17 Jul 2010 00:16:50 -0700 Subject: [PATCH] Fix bug in type analysis for ComprehensionNodes. --- Cython/Compiler/ExprNodes.py | 3 +++ tests/run/list_comprehension.pyx | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/run/list_comprehension.pyx diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 035f97e6..09c925f1 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 index 00000000..2360a713 --- /dev/null +++ b/tests/run/list_comprehension.pyx @@ -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 -- 2.26.2