Commit 24549d0c authored by Stefan Behnel's avatar Stefan Behnel

use normal constant calculation for special case to avoid inconsistencies

parent 1cae6142
...@@ -3284,12 +3284,6 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): ...@@ -3284,12 +3284,6 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
return sequence_node return sequence_node
def visit_PrimaryCmpNode(self, node): def visit_PrimaryCmpNode(self, node):
if not node.cascade:
self._calculate_const(node)
if node.has_constant_result():
return self._bool_node(node, node.constant_result)
return node
# calculate constant partial results in the comparison cascade # calculate constant partial results in the comparison cascade
left_node = node.operand1 left_node = node.operand1
self._calculate_const(left_node) self._calculate_const(left_node)
...@@ -3306,6 +3300,11 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations): ...@@ -3306,6 +3300,11 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
left_node = right_node left_node = right_node
cmp_node = cmp_node.cascade cmp_node = cmp_node.cascade
if not node.cascade:
if node.has_constant_result():
return self._bool_node(node, node.constant_result)
return node
# collect partial cascades: [[value, CmpNode...], [value, CmpNode, ...], ...] # collect partial cascades: [[value, CmpNode...], [value, CmpNode, ...], ...]
cascades = [[node.operand1]] cascades = [[node.operand1]]
......
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