From: Rico Tzschichholz Date: Tue, 18 Feb 2020 17:35:40 +0000 (+0100) Subject: vala: Don't process arguments of MethodCall if error is set X-Git-Tag: 0.47.92~16 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fkeep-around%2Fdfe4f15616ca0613ed87b6d19fb4a968db258421;p=thirdparty%2Fvala.git vala: Don't process arguments of MethodCall if error is set This caused criticals like: vala_method_get_closure: assertion 'self != NULL' failed --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 9586b63ec..e73bc0ac3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..7239c0c6c --- /dev/null +++ b/tests/semantic/methodcall-invalid-argument-lambda.test @@ -0,0 +1,8 @@ +Invalid Code + +void foo (int i) { +} + +void main () { + foo (() => {}); +} diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala index b9772fed8..4a15a6cb4 100644 --- a/vala/valamethodcall.vala +++ b/vala/valamethodcall.vala @@ -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) {