From 2327e18f7704a11b057bfa25ac75a2d1d33d068d Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 7 Dec 2018 20:07:24 +0100 Subject: [PATCH] Fixed exception on adding variable to table of which we dont know the context --- Upsilon/Binder/Binder.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index 90f6109..02e2a20 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -804,8 +804,12 @@ namespace Upsilon.Binder { var variable = (BoundVariableExpression)indexable.Identifier; var index = (BoundLiteralExpression)indexable.Index; - ((TableVariableSymbol)variable.Variable.VariableSymbol).Variables.Add(index.Value.ToString(), - new VariableSymbol(index.Value.ToString(), value.Type, false)); + 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; }