Skip to content

Commit 6fbea30

Browse files
author
Sébastien Geiser
committed
Ensure to not declare a strongly typed variable more than once.
1 parent b8e3b7f commit 6fbea30

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,6 +2121,9 @@ protected virtual bool EvaluateVarOrFunc(string expression, Stack<object> stack,
21212121
{
21222122
if (stack.Count == 1 && stack.Peek() is ClassOrEnumType classOrEnum)
21232123
{
2124+
if (Variables.ContainsKey(varFuncName))
2125+
throw new ExpressionEvaluatorSyntaxErrorException($"Can not declare a new variable named [{varFuncName}]. A variable with this name already exists");
2126+
21242127
stack.Pop();
21252128

21262129
Variables[varFuncName] = new StronglyTypedVariable

0 commit comments

Comments
 (0)