Commit 371b3568 authored by Stefan Behnel's avatar Stefan Behnel

strip mult-factor from empty list literals

parent 9ecf58c8
......@@ -3269,7 +3269,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
sequence_node = node.operand1
factor = node.operand2
self._calculate_const(factor)
if factor.constant_result != 1:
if factor.constant_result != 1 and sequence_node.args:
sequence_node.mult_factor = factor
self.visitchildren(sequence_node)
return sequence_node
......@@ -3278,7 +3278,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
sequence_node = node.operand2
factor = node.operand1
self._calculate_const(factor)
if factor.constant_result != 1:
if factor.constant_result != 1 and sequence_node.args:
sequence_node.mult_factor = factor
self.visitchildren(sequence_node)
return sequence_node
......
......@@ -278,3 +278,14 @@ def for_in_nested_listcomp():
[]
"""
return [x for x in [1, 2, 3] for _ in []]
@cython.test_fail_if_path_exists(
"//ListNode//IntNode",
)
def mult_empty_list():
"""
>>> mult_empty_list()
[]
"""
return 5 * [] * 100
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