beltoforion / muparserx

A C++ Library for Parsing Expressions with Strings, Complex Numbers, Vectors, Matrices and more.
http://beltoforion.de/en/muparserx
BSD 2-Clause "Simplified" License
136 stars 60 forks source link

type checking #122

Open lhommev opened 1 year ago

lhommev commented 1 year ago

Hi, I'm using this library and I am very pleased with the capabilities and performance. With vey large data to process, i see ~400K evaluations per seconds with 12 cores CPUs.

Anyway, i noticed that there is no exception thrown when doing this:

123 == "abc"

I would expect an error with this expression. Does this make sense to you ?

beltoforion commented 1 year ago

This is a bug. It should be false based on the type alone. I'm not even sure whats happening here that the result is true.

On closer inspection i think it is correct to just return false. At first i was under the assumption the return value is "true". In my mind throwing an exception should only be done if the expression is incorrect. In this case i would go with what JavaScript does.