This project has moved and is read-only. For the latest updates, please go here.

Problem with nulls

Jun 23, 2015 at 7:55 AM
Edited Jun 23, 2015 at 11:50 AM
First of all thank you for your work.
I have to evaluate expressions like this
if(null!=10d) -> 'System.NullReferenceException'
if expression is like this if(10d!=null) it works fine, but I have to use both.
Any solution? thank you

At the moment I replace null by Double.NaN and condition like Double.IsNaN() but I dont like this solution...
Jun 24, 2015 at 7:14 AM
Edited Jun 24, 2015 at 7:20 AM
I appears that the expression is being converted into

if((System.Double)null!=10d)

hence the nullreferenceexception

This probably has to do with my type inference code that attempts to cast the left and right sides of a binary operation to the same type. There is probably something I misunderstood about type inference from the C# specification, and it's quite hard to implement correctly.

I will take a look at my code again and let you know once I fix it.

For now perhaps you can try casting 10d to object, if you want to test against null?
Jun 24, 2015 at 1:25 PM
Thank you very much. The problem is that expressions are stored in a database and writed by inexperienced users, so they must be friendly, like if(${Measured}>10d)......
Then I replace ${Measured} by some variable value, and this value can be null...
Thank you again for your library.