From c1f4c8fb3727292f780c5ed984b968846f40edaa Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 28 Nov 2018 21:28:01 +0100 Subject: [PATCH] Fixes tests --- Upsilon/Binder/Binder.cs | 7 +++++-- Upsilon/Binder/VariableSymbol.cs | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index 275f9b7..ac0c197 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -277,8 +277,11 @@ namespace Upsilon.Binder { var fullStopIndexExpression = (BoundFullStopIndexExpression) expression; var indexerExpression = fullStopIndexExpression.Expression; - var indexerVariable = (TableVariableSymbol)ResolveVariable(indexerExpression); - return indexerVariable.Variables[fullStopIndexExpression.Index]; + var indexerVariable = ResolveVariable(indexerExpression); + if (indexerVariable.Type == Type.Table) + { + return ((TableVariableSymbol)indexerVariable).Variables[fullStopIndexExpression.Index]; + } } return null; } diff --git a/Upsilon/Binder/VariableSymbol.cs b/Upsilon/Binder/VariableSymbol.cs index 2f954f9..befa8e5 100644 --- a/Upsilon/Binder/VariableSymbol.cs +++ b/Upsilon/Binder/VariableSymbol.cs @@ -63,4 +63,16 @@ namespace Upsilon.Binder Variables = variables; } } + + public class UserDataVariableSymbol : VariableSymbol + { + public BoundTypeDefinition BoundTypeDefinition { get; } + + public UserDataVariableSymbol(string name, bool local, BoundTypeDefinition boundTypeDefinition) + :base (name, Type.UserData, local) + { + BoundTypeDefinition = boundTypeDefinition; + } + } + } \ No newline at end of file