Fix complex table/function variable handling

This commit is contained in:
Deukhoofd 2019-01-18 16:41:03 +01:00
parent f55e6d314d
commit bee6fad947
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 23 additions and 0 deletions

View File

@ -372,6 +372,29 @@ namespace Upsilon.Binder
return new VariableSymbol(fullStopIndexExpression.Index, Type.Unknown, true);
}
}
else if (expression.Kind == BoundKind.BoundIndexExpression)
{
var indexExpression = (BoundIndexExpression) expression;
var indexerExpression = indexExpression.Identifier;
var indexerVariable = ResolveVariable(indexerExpression, diagnostics);
if (indexerVariable == null)
{
diagnostics?.LogError("Can't resolve variable", expression.Span);
}
else if (indexerVariable.TypeContainer == Type.Table)
{
var tableVariable = (TableVariableSymbol)indexerVariable;
if (tableVariable.TypeContainer is CompositeTypeContainer compositeTypeContainer)
{
return new VariableSymbol("", compositeTypeContainer.Types[1], true);
}
return new VariableSymbol("", expression.Type, true);
}
else if (indexerVariable.TypeContainer == Type.Unknown)
{
return new VariableSymbol("", Type.Unknown, true);
}
}
else if (expression.Kind == BoundKind.BoundFunctionCallExpression)
{
return new VariableSymbol("", expression.Type, true);