Fix complex table/function variable handling
This commit is contained in:
		| @@ -372,6 +372,29 @@ namespace Upsilon.Binder | |||||||
|                     return new VariableSymbol(fullStopIndexExpression.Index, Type.Unknown, true); |                     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) |             else if (expression.Kind == BoundKind.BoundFunctionCallExpression) | ||||||
|             { |             { | ||||||
|                 return new VariableSymbol("", expression.Type, true); |                 return new VariableSymbol("", expression.Type, true); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user