Fixed issue where when throwing "function not found" error with no parameters would throw a useless exception

This commit is contained in:
Deukhoofd 2019-02-03 14:24:13 +01:00
parent a2c6943c3a
commit 4790cc74d2
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 8 additions and 1 deletions

View File

@ -88,10 +88,17 @@ namespace Upsilon.Evaluator
var function = (ScriptRuntimeFunction) statement;
var option = function.GetValidOption(parameters);
if (option == null)
{
if (parameters == null)
{
throw new EvaluationException(_script.FileName,
$"No function found with name '{functionName}' and no parameters.",
e.Span);
}
throw new EvaluationException(_script.FileName,
$"No function found with name '{functionName}' and available parameters {string.Join(", ", parameters.Select(x => $"{x.GetType().Name}"))}",
e.Span);
}
var result = option.Run(_diagnostics, parameters?.Select(x => x.ToScriptType()).ToArray(), _script, Scope, new TextSpan());
return result;
}