From 7a81a4db2c48efb0e8bb266ba3f42c1bce96106a Mon Sep 17 00:00:00 2001 From: arookas Date: Wed, 3 Feb 2016 23:22:54 -0500 Subject: [PATCH] Made use of the null return value --- ssc/context.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ssc/context.cs b/ssc/context.cs index 77c2e32..d641fca 100644 --- a/ssc/context.cs +++ b/ssc/context.cs @@ -98,10 +98,10 @@ namespace arookas { sunVariableSymbol DeclareVariable(sunIdentifier node, sunSymbolModifiers modifiers) { var local = (modifiers & sunSymbolModifiers.Local) != 0; var name = MangleSymbolName(node.Value, node.Location.ScriptId, false, local); - if (Scopes.Any(i => i.GetIsDeclared(name))) { + var symbol = Scopes.DeclareVariable(name); + if (symbol == null) { throw new sunRedeclaredVariableException(node); } - var symbol = Scopes.DeclareVariable(name); if (Scopes.Top.Type == sunScopeType.Script) { // global-scope variables are added to the symbol table SymbolTable.Add(symbol); } @@ -113,10 +113,11 @@ namespace arookas { sunConstantSymbol DeclareConstant(sunIdentifier node, sunExpression expression, sunSymbolModifiers modifiers) { var local = (modifiers & sunSymbolModifiers.Local) != 0; var name = MangleSymbolName(node.Value, node.Location.ScriptId, false, local); - if (Scopes.Any(i => i.GetIsDeclared(name))) { + var symbol = Scopes.DeclareConstant(name, expression); + if (symbol == null) { throw new sunRedeclaredVariableException(node); } - return Scopes.DeclareConstant(name, expression); + return symbol; } public sunStorableSymbol ResolveStorable(sunIdentifier node) {