Bug report #11475
bad bracket simplification in expression
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | |||
Category: | Expressions | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 19745 |
Description
I noticed that this expression1 - ( 2 -1 )
is simplified to 1 -2 - 1
leading to wrong result.
Associated revisions
expressions: keep brackets (fix #11475)
[fix #11475] expressions: add left and right associavity for dump of binary operators
complete test for left associativity
Expressions: preserve brackets for right-associative operators
Fixes #11475
History
#1
Updated by Jürgen Fischer almost 10 years ago
- Status changed from Open to Closed
Fixed in changeset 2c7378bb16f7e6433363340b9c16e40c3ad654ae.
#2
Updated by Martin Dobias almost 10 years ago
- Affected QGIS version changed from 2.4.0 to master
- Priority changed from Severe/Regression to Normal
- Status changed from Closed to Reopened
The code assumes that the binary operators are left associative - which is true except for the power operator:
>>> e=QgsExpression("(2^3)^2") >>> e.evaluate() 64.0 >>> e.dump() u'2 ^ 3 ^ 2' >>> QgsExpression(e.dump()).evaluate() 512.0
Given the fact that expressions like A^B^C are rare I'm lowering the priority.
#3
Updated by Denis Rouzaud over 9 years ago
#4 Updated by Anonymous about 9 years ago
- Status changed from Reopened to Closed
Fixed in changeset 8342739b375bb30fe2f751337078f0baefb51368.