Skip to content

Commit 3c24679

Browse files
author
Sébastien Geiser
committed
Better nullable types management
1 parent 332b1ec commit 3c24679

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
21842184
{
21852185
if (Variables.ContainsKey(varFuncName) && Variables[varFuncName] is StronglyTypedVariable stronglyTypedVariable)
21862186
{
2187-
if(cusVarValueToPush == null && !stronglyTypedVariable.Type.IsValueType)
2187+
if(cusVarValueToPush == null && stronglyTypedVariable.Type.IsValueType && Nullable.GetUnderlyingType(stronglyTypedVariable.Type) == null)
21882188
{
21892189
throw new ExpressionEvaluatorSyntaxErrorException($"Can not cast null to {stronglyTypedVariable.Type} because it's not a nullable valueType");
21902190
}

0 commit comments

Comments
 (0)