[vala/0.52] vala: Improve error message for invalid handler of dynamic signal
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.52] vala: Improve error message for invalid handler of dynamic signal
- Date: Sun, 14 Nov 2021 12:15:21 +0000 (UTC)
commit 67c4b9dd49841c7660bddde6b5cb8a47e10cbffa
Author: Lorenz Wildberg <lorenz wild-fisch de>
Date: Fri Oct 29 11:50:30 2021 +0100
vala: Improve error message for invalid handler of dynamic signal
tests/Makefile.am | 1 +
tests/objects/signals-dynamic-lambda-handler.test | 8 ++++++++
vala/valamemberaccess.vala | 6 +++++-
3 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2951db733..f862af631 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -523,6 +523,7 @@ TESTS = \
objects/signals-delegate.vala \
objects/signals-delegate-parameter.vala \
objects/signals-dymanic-invalid-handler.test \
+ objects/signals-dynamic-lambda-handler.test \
objects/signals-error-marshal.vala \
objects/signals-fundamental-return.vala \
objects/signals-gobject-return.vala \
diff --git a/tests/objects/signals-dynamic-lambda-handler.test
b/tests/objects/signals-dynamic-lambda-handler.test
new file mode 100644
index 000000000..ae86c9f1c
--- /dev/null
+++ b/tests/objects/signals-dynamic-lambda-handler.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+void main () {
+ dynamic Object? foo = null;
+ foo.on_bar.connect ((baz) => {
+ // lambdas are not allowed
+ });
+}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 82fe8d2d9..a251ef118 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -480,7 +480,11 @@ public class Vala.MemberAccess : Expression {
unowned MemberAccess? arg = s.handler as MemberAccess;
if (arg == null || !arg.check (context) ||
!(arg.symbol_reference is Method)) {
error = true;
- Report.error (s.handler.source_reference,
"Invalid handler for `%s'", s.get_full_name ());
+ if (s.handler is LambdaExpression) {
+ Report.error
(s.handler.source_reference, "Lambdas are not allowed for dynamic signals");
+ } else {
+ Report.error
(s.handler.source_reference, "Cannot infer call signature for dynamic signal `%s' from given expression",
s.get_full_name ());
+ }
}
}
s.access = SymbolAccessibility.PUBLIC;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]