diff --git a/Upsilon/StandardLibraries/StaticScope.cs b/Upsilon/StandardLibraries/StaticScope.cs index e74aa90..24d0f19 100644 --- a/Upsilon/StandardLibraries/StaticScope.cs +++ b/Upsilon/StandardLibraries/StaticScope.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -110,7 +111,7 @@ namespace Upsilon.StandardLibraries var parameters = new List(); for (var i = 0; i < genericParameters.Length - 1; i++) { - var t = genericParameters[i].GetScriptType(); + var t = DeriveValidTypes(genericParameters[i]); parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)); } @@ -121,13 +122,9 @@ namespace Upsilon.StandardLibraries private static VariableSymbol BuildActionVariableSymbol(string name, System.Type type) { var genericParameters = type.GetGenericArguments(); - var parameters = new List(); - for (var i = 0; i < genericParameters.Length; i++) - { - var t = genericParameters[i].GetScriptType(); - parameters.Add(new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)); - } - return new InternalFunctionVariableSymbol(name, true, Type.Nil, parameters.ToArray()); + return new InternalFunctionVariableSymbol(name, true, Type.Nil, + genericParameters.Select(DeriveValidTypes).Select(t => + new InternalFunctionVariableSymbol.InternalFunctionParameter(t, false)).ToArray()); } private static Type DeriveValidTypes(System.Type type) @@ -145,8 +142,15 @@ namespace Upsilon.StandardLibraries if (type == typeof(ScriptType)) // allows every type return (Type) 255; + if (type == typeof(object)) + // allows every type + return (Type) 255; if (type.IsEnum) return Type.Number; + if (type == typeof(string)) + return Type.String; + if (typeof(IEnumerable).IsAssignableFrom(type)) + return Type.Table | Type.UserData; return Type.UserData; } }