Commit 65705d06 authored by Stefan Behnel's avatar Stefan Behnel

Merge branch '0.27.x'

parents 14b08598 2ad640d1
......@@ -7984,6 +7984,7 @@ class ComprehensionNode(ScopedExprNode):
child_attrs = ["loop"]
is_temp = True
constant_result = not_a_constant
def infer_type(self, env):
return self.type
......
......@@ -150,6 +150,57 @@ def listcomp_const_condition_false():
return [x*2 for x in range(3) if False]
@cython.test_fail_if_path_exists("//IfStatNode",
"//ComprehensionAppendNode")
@cython.test_assert_path_exists("//ComprehensionNode")
def listcomp_const_condition_false_bool_test():
"""
>>> listcomp_const_condition_false_bool_test()
True
"""
return not [l for l in [1] if False]
@cython.test_fail_if_path_exists("//IfStatNode",
"//ComprehensionAppendNode")
@cython.test_assert_path_exists("//ComprehensionNode")
def listcomp_const_condition_false_assert():
"""
>>> listcomp_const_condition_false_assert()
"""
assert not [l for l in [1] if False]
@cython.test_fail_if_path_exists("//ComprehensionNode//IfStatNode",
"//ComprehensionAppendNode")
@cython.test_assert_path_exists("//ComprehensionNode",
"//IfStatNode")
def listcomp_const_condition_false_if():
"""
>>> listcomp_const_condition_false_if()
True
"""
if not [l for l in [1] if False]:
return True
return False
@cython.test_fail_if_path_exists("//ComprehensionNode//IfStatNode",
"//ComprehensionAppendNode")
@cython.test_assert_path_exists("//ComprehensionNode",
"//IfStatNode")
def listcomp_const_condition_false_typed_error():
"""
>>> listcomp_const_condition_false_typed_error() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError: ...
"""
cdef str l
if not [l for l in [1] if False]:
return True
return False
@cython.test_fail_if_path_exists("//IfStatNode")
@cython.test_assert_path_exists("//ComprehensionNode",
"//ComprehensionAppendNode")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment