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

Support for null compared to other types

Jan 12, 2012 at 7:46 PM

I have the following expression:

null == true

I am running this expression using the SampleExpressionEvaluator grammar. I also added the following lines in the RunSample method of the ExpressionEvaluatorGrammar class:

_evaluator.Globals.Add("null", null);
_evaluator.Globals.Add("true", true);
_evaluator.Globals.Add("false", false);

When I run the expression above with the grammar mentioned above in the Irony Grammar Explorer I get the following error:

Error: Variable unassigned. At (1:1).

What do I need to do so that null objects and other types (in this case a boolean) can be compared to each other?

Jan 12, 2012 at 8:21 PM

that's a good question - and it turns out, I do not have an easy answer. For now, the "null" and object comparison is not supported in evaluator. I need to think a bit about this, will try to solve and push in the next update. I guess I need to use IEquatable if any of the objects in expression supports this...