sklose/NCalc2

Comparing null to custom function crashes

rhaikonen opened this issue · 2 comments

Expression like "F(1) == null", where F(1) is custom function, throws exception:
System.NullReferenceException : Object reference not set to an instance of an object. at System.Object.GetType() at NCalc.Domain.EvaluationVisitor.CompareUsingMostPreciseType(Object a, Object b) at NCalc.Domain.EvaluationVisitor.Visit(BinaryExpression expression) at NCalc.Expression.Evaluate()

F(1) can return null or not null objects.

This is an issue with all known Ncalc clones, even with the original, except Ncalc-Edge 1.4.1.000. We are forced to use that version and I'd like to use your much faster one.

@rhaikonen Can you write some code here that I can implement in a test to try and correct this?

@rhaikonen I can't quite get a test that matches what you're describing, but see if that pull request helps.