zzzprojects / Eval-Expression.NET

C# Eval Expression | Evaluate, Compile, and Execute C# code and expression at runtime.
https://eval-expression.net/
Other
449 stars 86 forks source link

brackets mismatch #43

Closed technieray closed 5 years ago

technieray commented 5 years ago

I just discovered a problem with brackets. Ex. ((1=1) or ((2=2) the above formula considered as a legit expression and able to evaluate. Can you please fix. Thanks

JonathanMagnan commented 5 years ago

Hello @Platform101 ,

Why is that considered legit?

In the expression, there is 2 more open parenthesis that it has of closing parenthesis.

So I don't expect it works either.

Best Regards,

Jonathan

technieray commented 5 years ago

Thanks for reply @JonathanMagnan. it actually worked and returns true..

var evalContext=new EvalContext(); var test=evalContext.Compile<Func<T, bool>>("((1=1) or ((2=2)"); var result= test(obj);

The generic T is just an empty class and obj just a new Class();

JonathanMagnan commented 5 years ago

Hello @Platform101 ,

Could you reproduce it on a Fiddle?

On my side, it still doesn't work as expected: https://dotnetfiddle.net/Za0Rpd

technieray commented 5 years ago

Hi @JonathanMagnan, there are some syntax error in the above. Here is the working one

https://dotnetfiddle.net/a3eL76

JonathanMagnan commented 5 years ago

Thank @Platform101 ,

We will look at it.

I know that our library fixes some syntax error but that's really weird that one work!

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @Platform101 ,

It has been a while, sorry for the delay.

That issue with several other (parameter, index, generic type) has been fixed and should now correctly show an error message starting from v1.8.0

Example: https://dotnetfiddle.net/8VXV6O

Let me know if everything works now as expected.

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @Platform101 ,

This issue will be closed since it has been resolved.

Feel free to reopen it if you feel otherwise.

Best Regards,

Jonathan