return base
return node
+ def visit_ComprehensionNode(self, node):
+ self.visitchildren(node)
+ if isinstance(node.loop, Nodes.StatListNode) and not node.loop.stats:
+ # loop was pruned already => transform into literal
+ return node.target
+ return node
+
def visit_ForInStatNode(self, node):
self.visitchildren(node)
sequence = node.iterator.sequence
@cython.test_fail_if_path_exists(
+ "//ComprehensionNode",
"//ForInStatNode",
)
@cython.test_assert_path_exists(
- "//ComprehensionNode",
+ "//ListNode",
)
def for_in_empty_listcomp():
"""
@cython.test_fail_if_path_exists(
+ "//ComprehensionNode",
"//ForInStatNode",
)
@cython.test_assert_path_exists(
- "//ComprehensionNode",
+ "//ListNode",
)
def for_in_empty_nested_listcomp():
"""
@cython.test_fail_if_path_exists(
"//ForInStatNode//ForInStatNode",
- )
+)
@cython.test_assert_path_exists(
"//ForInStatNode",
"//ComprehensionNode",
@cython.test_fail_if_path_exists(
+ "//ComprehensionNode",
"//ForInStatNode",
)
@cython.test_assert_path_exists(
- "//ComprehensionNode",
+ "//SetNode",
)
def for_in_empty_setcomp():
"""