Fixed exception on adding variable to table of which we dont know the context

This commit is contained in:
Deukhoofd 2018-12-07 20:07:24 +01:00
parent 229fe3bffa
commit 2327e18f77
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 6 additions and 2 deletions

View File

@ -804,9 +804,13 @@ namespace Upsilon.Binder
{
var variable = (BoundVariableExpression)indexable.Identifier;
var index = (BoundLiteralExpression)indexable.Index;
((TableVariableSymbol)variable.Variable.VariableSymbol).Variables.Add(index.Value.ToString(),
var variableSymbol = variable.Variable.VariableSymbol;
if (variableSymbol is TableVariableSymbol tableVariableSymbol)
{
tableVariableSymbol.Variables.Add(index.Value.ToString(),
new VariableSymbol(index.Value.ToString(), value.Type, false));
}
}
indexableExpression = indexable;
}
else