From: Rico Tzschichholz Date: Tue, 27 Nov 2018 15:11:29 +0000 (+0100) Subject: vala: Make check_arguments() more verbose and don't bail on first error X-Git-Tag: 0.42.4~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69cd0041d2f8aced2c7a7d9f7ebc523dafc73d62;p=thirdparty%2Fvala.git vala: Make check_arguments() more verbose and don't bail on first error Fixes https://gitlab.gnome.org/GNOME/vala/issues/438 --- diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index 3a5dea6fe..139103b89 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -407,6 +407,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public bool check_arguments (Expression expr, DataType mtype, List params, List args) { + bool error = false; + Expression prev_arg = null; Iterator 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) {