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

View File

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