Diagnostic for invalid number of parameters
This commit is contained in:
parent
6bb8139f40
commit
5f9c32874a
|
@ -200,6 +200,12 @@ namespace Upsilon.Binder
|
|||
{
|
||||
var variableExpression =(BoundVariableExpression) expression;
|
||||
var function = (FunctionVariableSymbol)variableExpression.Variable.VariableSymbol;
|
||||
if (function.Parameters.Length != parameters.Count)
|
||||
{
|
||||
_diagnostics.LogError($"Invalid number of parameters for function '{function.Name}'. " +
|
||||
$"Expected '{function.Parameters.Length}', got '{parameters.Count}'", e.Span);
|
||||
return new BoundLiteralExpression(new ScriptNull(), e.Span);
|
||||
}
|
||||
if (!function.IsBound)
|
||||
{
|
||||
Scope = new BoundScope(Scope);
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Upsilon.Parser
|
|||
OpenParenthesis = openParenthesis;
|
||||
Parameters = parameters;
|
||||
CloseParenthesis = closeParenthesis;
|
||||
Span = new TextSpan(Identifier.Span.Start, CloseParenthesis.Span.End - Identifier.Span.End);
|
||||
Span = new TextSpan(Identifier.Span.Start, CloseParenthesis.Span.End - Identifier.Span.Start);
|
||||
}
|
||||
|
||||
public override SyntaxKind Kind => SyntaxKind.FunctionCallExpression;
|
||||
|
|
|
@ -202,15 +202,15 @@ namespace Upsilon.Parser
|
|||
var functionToken = MatchToken(SyntaxKind.FunctionKeyword);
|
||||
var openParenthesis = MatchToken(SyntaxKind.OpenParenthesis);
|
||||
var variableBuilder = ImmutableArray.CreateBuilder<IdentifierToken>();
|
||||
IdentifierToken lastIdentifier = null;
|
||||
SyntaxToken current = null;
|
||||
while (Current.Kind != SyntaxKind.CloseParenthesis)
|
||||
{
|
||||
var variableIdentifier = (IdentifierToken)MatchToken(SyntaxKind.Identifier);
|
||||
if (lastIdentifier == variableIdentifier)
|
||||
if (Current == current)
|
||||
{
|
||||
break;
|
||||
}
|
||||
lastIdentifier = variableIdentifier;
|
||||
current = Current;
|
||||
var variableIdentifier = (IdentifierToken)MatchToken(SyntaxKind.Identifier);
|
||||
variableBuilder.Add(variableIdentifier);
|
||||
if (Current.Kind == SyntaxKind.Comma)
|
||||
NextToken();
|
||||
|
|
Loading…
Reference in New Issue