Fix function calls in fullstop index expressions not binding properly

This commit is contained in:
Deukhoofd 2019-01-21 18:45:02 +01:00
parent a9f6b682dc
commit e5f08d5859
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
2 changed files with 43 additions and 38 deletions

View File

@ -230,9 +230,8 @@ namespace Upsilon.Binder
{
if (function is ScriptFunctionVariableSymbol scriptFunction)
{
if (!(scriptFunction.GetFirstValid(parameters.Select(x => x.Type).ToArray()) is ScriptFunctionVariableOption functionOption))
throw new Exception();
if ((scriptFunction.GetFirstValid(parameters.Select(x => x.Type).ToArray()) is ScriptFunctionVariableOption functionOption))
{
if (!functionOption.IsBound)
{
Scope = new BoundScope(Scope);
@ -271,6 +270,7 @@ namespace Upsilon.Binder
}
}
}
else
{
if (string.Equals(function.Name, "require") && parameters.Count > 0)
@ -432,6 +432,11 @@ namespace Upsilon.Binder
}
else if (expression.Kind == BoundKind.BoundFunctionCallExpression)
{
if (expression.Type == Type.UserData)
{
var boundDef = BoundTypeHandler.GetTypeDefinition(expression.Type.UserData);
return new UserDataVariableSymbol("", boundDef, true);
}
return new VariableSymbol("", expression.Type, true);
}
else if (expression.Type == Type.Unknown)

View File

@ -28,7 +28,7 @@ namespace Upsilon.Binder
{
get
{
Type? valueType = null;
TypeContainer valueType = null;
foreach (var statement in Statements)
{
if (!(statement is BoundExpressionStatement exp))
@ -36,7 +36,7 @@ namespace Upsilon.Binder
valueType = BaseTypes.Type.Unknown;
break;
}
if (!valueType.HasValue)
if (valueType == null)
{
valueType = exp.Expression.Type;
continue;
@ -46,9 +46,9 @@ namespace Upsilon.Binder
break;
}
var valueRealType = BaseTypes.Type.Unknown;
if (valueType.HasValue)
valueRealType = valueType.Value;
TypeContainer valueRealType = BaseTypes.Type.Unknown;
if (valueType != null)
valueRealType = valueType;
var arr = new TypeContainer[] {BaseTypes.Type.String, valueRealType};
return new CompositeTypeContainer()