[Bugfix] Expression: fix precedence+associativity management in parenthesis removal
Fixes #6948
This commit is contained in:
@@ -1517,7 +1517,7 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const
|
||||
leftOperator = static_cast<OperatorExpression*>(left)->op;
|
||||
if (left->priority() < priority()) // Check on operator priority first
|
||||
needsParens = true;
|
||||
else if (leftOperator == op) { // Equal priority?
|
||||
else if (leftOperator == op) { // Same operator ?
|
||||
if (!isLeftAssociative())
|
||||
needsParens = true;
|
||||
//else if (!isCommutative())
|
||||
@@ -1588,14 +1588,14 @@ void OperatorExpression::_toString(std::ostream &s, bool persistent,int) const
|
||||
rightOperator = static_cast<OperatorExpression*>(right)->op;
|
||||
if (right->priority() < priority()) // Check on operator priority first
|
||||
needsParens = true;
|
||||
else if (rightOperator == op) { // Equal priority?
|
||||
else if (rightOperator == op) { // Same operator ?
|
||||
if (!isRightAssociative())
|
||||
needsParens = true;
|
||||
else if (!isCommutative())
|
||||
needsParens = true;
|
||||
}
|
||||
else if (right->priority() == priority()) {
|
||||
if (!isRightAssociative())
|
||||
else if (right->priority() == priority()) { // Same priority ?
|
||||
if (!isRightAssociative() || rightOperator == MOD)
|
||||
needsParens = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,6 +1551,7 @@ class DocumentExpressionCases(unittest.TestCase):
|
||||
# must not raise a topological error
|
||||
self.assertEqual(self.Doc.recompute(), 2)
|
||||
|
||||
|
||||
def testIssue4649(self):
|
||||
class Cls():
|
||||
def __init__(self, obj):
|
||||
|
||||
Reference in New Issue
Block a user