Skip to content

Commit f394119

Browse files
author
Sébastien Geiser
committed
Manage typed variables without init.
1 parent d111dce commit f394119

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,10 +2114,12 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
21142114
{
21152115
stack.Push(varValueToPush);
21162116
}
2117-
else if ((Variables.TryGetValue(varFuncName, out object cusVarValueToPush) || varFuncMatch.Groups["assignationOperator"].Success)
2118-
&& (cusVarValueToPush == null || !TypesToBlock.Contains(cusVarValueToPush.GetType())))
2117+
else if ((Variables.TryGetValue(varFuncName, out object cusVarValueToPush)
2118+
|| varFuncMatch.Groups["assignationOperator"].Success
2119+
|| (stack.Count == 1 && stack.Peek() is ClassOrEnumType && string.IsNullOrWhiteSpace(expression.Substring(i)))
2120+
&& (cusVarValueToPush == null || !TypesToBlock.Contains(cusVarValueToPush.GetType()))))
21192121
{
2120-
if (stack.Count == 1 && stack.Peek() is ClassOrEnumType classOrEnum && varFuncMatch.Groups["assignationOperator"].Success)
2122+
if (stack.Count == 1 && stack.Peek() is ClassOrEnumType classOrEnum)
21212123
{
21222124
stack.Pop();
21232125

0 commit comments

Comments
 (0)