Closed void80 closed 3 months ago
Hello @void80 ,
Thank you for reporting.
Your suspicion is probably 100% right. I remember we fixed a similar issue recently but slightly different #154 (he wanted to cast it on his side).
We will look at it.
Best Regards,
Jon
We've figured out that a downgrade to 6.0.1 works around the problem, in case this helps you. Best regards, Sebastian
Hello @strohhaecker , @void80
A new version, v6.1.7
, has been released today.
All known cases we found have been fixed in this issue.
Could you test the latest version and let us know if everything is working? Or report any missing expression that still have an error.
Best Regards,
Jon
Hi Jon, I'll try to verify this fixes some problems we had, though we have changed a lot around the expression evaluation since that time. Thanks for keeping this up! Sebastian
Hi Jon,
we verified that all of our use cases work with the version 6.1.7.
However, I just wanted to check some cases we are not using. There seems to be one problem remaining (which we are not using).
[TestMethod]
[DataRow("#1", "a1", 1)]
[DataRow("#2", "(a1)", 1)]
[DataRow("#3", "(a1)+(a1)", 2)]
[DataRow("#4", "(a1)+a1", 2)]
[DataRow("#5", "(a1)-(a1)", 0)]
[DataRow("#6", "(a1)-a1", 0)]
[DataRow("#7", "(int)-1", -1)]
[DataRow("#8", "(int)+1", +1)]
[DataRow("#9", "+1", +1)]
public void TestSimpleFalseCastExpressions(string id, string expression, int expected)
{
var context = new EvalContext();
var types = new Dictionary<string, Type>
{
{ "a1", typeof(double) },
};
var values = new Dictionary<object, double>
{
{ "a1", 1.0 },
};
var compiled = context.Compile(expression, types);
var result = compiled.Invoke(values);
result.Should().Be(expected);
}
Use case #8 is not working. That is, a cast followed by a unary + operator. Strangely enough, the unary operator itself seems to work (case #9).
Regards Sven
Thank you @void80 for reporting.
Indeed, we only added the logic for the minus
sign, never for the plus
sign. We will see if it is worth doing a similar logic (we are more afraid of the side impact here).
Best Regards,
Jon
Hello @void80 ,
The v6.1.8 has been released.
We added an identical logic to the plus
sign that we did with the minus
sign.
Let me know if this time everything is working as expected.
Best Regards,
Jon
Have a look at the following test cases
The cases #5 and #6 fail with the following exception:
My suspicion is that
(a1)
is (wrongly) interpreted as cast when followed by a-
sign, because the-
is interpreted as unary negation operator.I would expect the parser to be able to distinguish between a real cast and an expression in parens.
For example
"(double) -1"
should be identified as a cast,"(a1)-1"
should be identified as a subtraction.