From 07043e1ab4179b986aef43784ca8f8a05096a10a Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 13 Dec 2018 19:04:23 +0100 Subject: [PATCH] Fixes for binding --- Upsilon/Binder/Binder.cs | 3 ++- .../VariableSymbols/InternalFunctionVariableSymbol.cs | 6 ++++-- Upsilon/StandardLibraries/StaticScope.cs | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Upsilon/Binder/Binder.cs b/Upsilon/Binder/Binder.cs index 3f80d73..0966fbf 100644 --- a/Upsilon/Binder/Binder.cs +++ b/Upsilon/Binder/Binder.cs @@ -289,7 +289,8 @@ namespace Upsilon.Binder { if (udSymbol.Parent != null ) { - if (udSymbol.Parent.Properties.TryGetValue(resolved.Name, out var ubProperty) && ubProperty is UserDataBoundMethod ubMethod) + if (udSymbol.Parent.Properties.TryGetValue(resolved.Name.ToLowerInvariant(), + out var ubProperty) && ubProperty is UserDataBoundMethod ubMethod) { returnType = ubMethod.ResultType; var (isValid, error, wrongParameter) = ubMethod.ValidateParameters(parameters.ToImmutable()); diff --git a/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs b/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs index 5ed51ff..08d3485 100644 --- a/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs +++ b/Upsilon/Binder/VariableSymbols/InternalFunctionVariableSymbol.cs @@ -9,17 +9,19 @@ namespace Upsilon.Binder.VariableSymbols { public class InternalFunctionParameter { - public InternalFunctionParameter(Type type, bool isOptional) + public InternalFunctionParameter(string name, Type type, bool isOptional) { ValidTypes = type; IsOptional = isOptional; + Name = name; } + public string Name { get; } public Type ValidTypes { get; } public bool IsOptional { get; } } - private InternalFunctionParameter[] FunctionParameters { get; } + public InternalFunctionParameter[] FunctionParameters { get; } private int MinimalParametersRequired { get; } public InternalFunctionVariableSymbol(string name, bool local, Type resultType, InternalFunctionParameter[] functionParameters) diff --git a/Upsilon/StandardLibraries/StaticScope.cs b/Upsilon/StandardLibraries/StaticScope.cs index 8d8a3be..c61eeab 100644 --- a/Upsilon/StandardLibraries/StaticScope.cs +++ b/Upsilon/StandardLibraries/StaticScope.cs @@ -63,7 +63,7 @@ namespace Upsilon.StandardLibraries func.Value.MethodInfoFunction.GetParameterInfo().Select(typeInfo => { var derivedType = DeriveValidTypes(typeInfo.Type); - return new InternalFunctionVariableSymbol.InternalFunctionParameter(derivedType, + return new InternalFunctionVariableSymbol.InternalFunctionParameter(func.Key, derivedType, typeInfo.IsOptional); }).ToArray()) { @@ -123,7 +123,7 @@ namespace Upsilon.StandardLibraries for (var i = 0; i < genericParameters.Length - 1; i++) { var t = DeriveValidTypes(genericParameters[i]); - parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)); + parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(name, t, false)); } } @@ -136,7 +136,7 @@ namespace Upsilon.StandardLibraries var genericParameters = type.GetGenericArguments(); return new InternalFunctionVariableSymbol(name, true, Type.Nil, genericParameters.Select(DeriveValidTypes).Select(t => - new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)).ToArray()); + new InternalFunctionVariableSymbol.InternalFunctionParameter(name, t, false)).ToArray()); } public static Type DeriveValidTypes(System.Type type)