[vala/wip/ricotz/lsp-rev: 1/4] vala: Don't process arguments of MethodCall if error is set
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/ricotz/lsp-rev: 1/4] vala: Don't process arguments of MethodCall if error is set
- Date: Tue, 18 Feb 2020 17:49:46 +0000 (UTC)
commit d0e7087cb1a9e37d8a0d3c0435549fba79d128a3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Feb 18 18:35:40 2020 +0100
vala: Don't process arguments of MethodCall if error is set
This caused criticals like:
vala_method_get_closure: assertion 'self != NULL' failed
tests/Makefile.am | 1 +
tests/semantic/methodcall-invalid-argument-lambda.test | 8 ++++++++
vala/valamethodcall.vala | 7 +++++--
3 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9586b63ec..61ab255fa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -815,6 +815,7 @@ TESTS = \
semantic/method-too-many-type-arguments.test \
semantic/method-virtual.test \
semantic/method-virtual-body.test \
+ semantic/methodcall-invalid-argument-lambda.test \
semantic/methodcall-field-initializer-throws.test \
semantic/methodcall-void-expression.test \
semantic/methodcall-yield-with-begin.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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]