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