]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Make check_arguments() more verbose and don't bail on first error
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 15:11:29 +0000 (16:11 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 15:40:03 +0000 (16:40 +0100)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/438

vala/valasemanticanalyzer.vala

index 3a5dea6fe0986f5328ff8dd400d83409834dea1e..139103b895d5bbd088c95deae4aa500ff690dd4a 100644 (file)
@@ -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) {