-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expression evaluation errors #30
Comments
My fault, one correction: when i swap the sub-expressions to get (in the very simple case): Then the whole expression evaluates correctly when using X from both ranges (15 and 35 for example). So it seems that if expressions go from smaller to bigger it works fine. |
Further research... As i have no time now to dig into this bug myself, i tried to walk around it like this:
This way it works fine. But when i add another condition to the expression, like this: Then I get panic:
The value that is passed to the function is for some reason |
Looks like this is due to some post-processing that happens when the expression builds the evaluation stage tree. There is logic built as part of #21 which rearranges the tree to make sure that identical operators of the same precedence work as written - but it looks like it's messing up the order of comparators. The first case evaluates the very last compare ( I was able to put together a quick fix by disabling the rearrangement logic for logical operators and comparators, but there's still a larger problem with the stage rearrangement logic. Still looking at it. |
Can i peek at the fix? :) By the way, i already tried some time ago to disable reorderStages(), it just reverses the behavior - the first comparison works, while the second does not. |
Just now pushed 8435889 to master, since the tests are good to have and the fix works for these specific cases. I'm positive that it doesn't completely correct the root problem though. It seems to be a problem with logical operators, specifically (not comparators, like i thought). A case like |
Thank you very much, it works like a charm now! |
After scrutinizing it more, it looks like it really was just a problem with stage reordering and the logical operators. I can't find any other cases that exhibit the behavior, and those are the only operators which should never be reordered, so it looks like there's no followup. Thanks for using the library, and for the detailed report! |
Hello and thanks for the useful library, but i've got an issue with it.
I have a quite simple expression:
([X] >= 2887057408 && [X] <= 2887122943) || ([X] >= 168100864 && [X] <= 168118271)
If i pass X = 2887057409, which satisfies first expression in parenthesis, the expression is for some reason evaluated to FALSE.
If i pass X = 168100865, which satisfies second part of an expression in parenthesis, i get TRUE.
If i swap the sub-expressions, then i get the inverted behaviour.
If i use smaller numbers, like:
([X] >= 0 && [X] <= 10) || ([X] >= 20 && [X] <= 30)
then the expression is evaluated right in all cases.
I think the problem is with numbers being converted to float64, however looking at tokens after expression compilation the numbers seem fine:
{Kind:13 Value:40} {Kind:7 Value:X} {Kind:10 Value:>=} {Kind:2 Value:2.887057408e+09} {Kind:11 Value:&&} {Kind:7 Value:X} {Kind:10 Value:<=} {Kind:2 Value:2.887122943e+09} {Kind:14 Value:41} {Kind:11 Value:||} {Kind:13 Value:40} {Kind:7 Value:X} {Kind:10 Value:>=} {Kind:2 Value:1.68100864e+08} {Kind:11 Value:&&} {Kind:7 Value:X} {Kind:10 Value:<=} {Kind:2 Value:1.68118271e+08} {Kind:14 Value:41}
And this does not explain why the behaviour changes if i just reverse the parts before and after || operator...
The text was updated successfully, but these errors were encountered: