Commit 4aca8df6 authored by Rico Tzschichholz's avatar Rico Tzschichholz

vala: Make check_arguments() more verbose and don't bail on first error

Fixes GNOME/vala#438
parent f2682b11
......@@ -407,6 +407,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
public bool check_arguments (Expression expr, DataType mtype, List<Parameter> params, List<Expression> args) {
bool error = false;
Expression prev_arg = null;
Iterator<Expression> arg_it = args.iterator ();
......@@ -425,7 +427,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var arg = arg_it.get ();
if (!check_argument (arg, i, param.direction)) {
expr.error = true;
return false;
error = true;
}
i++;
......@@ -443,7 +445,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else {
Report.error (expr.source_reference, "Too few arguments, method `%s' does not take %d arguments".printf (mtype.to_string (), args.size));
}
return false;
error = true;
} else {
var invocation_expr = expr as MethodCall;
var object_creation_expr = expr as ObjectCreationExpression;
......@@ -460,7 +462,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var arg = arg_it.get ();
if (!check_argument (arg, i, param.direction)) {
expr.error = true;
return false;
error = true;
}
prev_arg = arg;
......@@ -471,7 +473,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (ellipsis && !check_variadic_arguments (arg_it, i, expr.source_reference)) {
expr.error = true;
return false;
error = true;
} else if (!ellipsis && arg_it != null && arg_it.next ()) {
expr.error = true;
var m = mtype as MethodType;
......@@ -480,7 +482,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
} else {
Report.error (expr.source_reference, "Too many arguments, method `%s' does not take %d arguments".printf (mtype.to_string (), args.size));
}
return false;
error = true;
}
if (diag && prev_arg != null) {
......@@ -490,7 +492,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
}
return true;
return !error;
}
bool check_argument (Expression arg, int i, ParameterDirection direction) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment