]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Don't process arguments of MethodCall if error is set dfe4f15616ca0613ed87b6d19fb4a968db258421
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Feb 2020 17:35:40 +0000 (18:35 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Feb 2020 17:51:41 +0000 (18:51 +0100)
This caused criticals like:

  vala_method_get_closure: assertion 'self != NULL' failed

tests/Makefile.am
tests/semantic/methodcall-invalid-argument-lambda.test [new file with mode: 0644]
vala/valamethodcall.vala

index 9586b63ec66e57983a8d97483969d7cb9eced4a3..e73bc0ac360c0c1cd93c23a42972610a3ca6a5df 100644 (file)
@@ -816,6 +816,7 @@ TESTS = \
        semantic/method-virtual.test \
        semantic/method-virtual-body.test \
        semantic/methodcall-field-initializer-throws.test \
+       semantic/methodcall-invalid-argument-lambda.test \
        semantic/methodcall-void-expression.test \
        semantic/methodcall-yield-with-begin.test \
        semantic/objectcreation-abstract-class.test \
diff --git a/tests/semantic/methodcall-invalid-argument-lambda.test b/tests/semantic/methodcall-invalid-argument-lambda.test
new file mode 100644 (file)
index 0000000..7239c0c
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo (int i) {
+}
+
+void main () {
+       foo (() => {});
+}
index b9772fed8a814f9f07f46c880a8b0dfa783540a8..4a15a6cb4ab8de48329a6b7210a69354cdb01860 100644 (file)
@@ -473,7 +473,10 @@ public class Vala.MethodCall : Expression {
 
                bool force_lambda_method_closure = false;
                foreach (Expression arg in argument_list) {
-                       arg.check (context);
+                       if (!arg.check (context)) {
+                               error = true;
+                               continue;
+                       }
 
                        if (arg is LambdaExpression && ((LambdaExpression) arg).method.closure) {
                                force_lambda_method_closure = true;
@@ -481,7 +484,7 @@ public class Vala.MethodCall : Expression {
                }
                // force all lambda arguments using the same closure scope
                // TODO https://gitlab.gnome.org/GNOME/vala/issues/59
-               if (force_lambda_method_closure) {
+               if (!error && force_lambda_method_closure) {
                        foreach (Expression arg in argument_list) {
                                unowned LambdaExpression? lambda = arg as LambdaExpression;
                                if (lambda != null && lambda.method.binding != MemberBinding.STATIC) {