[vala/wip/issue/658: 23/30] corrected anonymous delegate parser and fail tests
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/658: 23/30] corrected anonymous delegate parser and fail tests
- Date: Wed, 21 Oct 2020 10:33:12 +0000 (UTC)
commit 3feffdf61db33e4be653186c7c6d039363d65a09
Author: Nick Schrader <nick schrader mailbox org>
Date: Sat Oct 17 01:06:14 2020 -0300
corrected anonymous delegate parser and fail tests
tests/Makefile.am | 3 +++
tests/delegates/anonymous-initializer.test | 19 +++++++++++++++++++
tests/delegates/anonymous-throws.test | 21 +++++++++++++++++++++
tests/delegates/anonymous-variadic.test | 19 +++++++++++++++++++
vala/valaparser.vala | 11 -----------
5 files changed, 62 insertions(+), 11 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4cfc4abd9..6a8158b06 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -337,6 +337,9 @@ TESTS = \
delegates/anonymous.vala \
delegates/anonymous-array.vala \
delegates/anonymous-type-param.vala \
+ delegates/anonymous-throws.test \
+ delegates/anonymous-variadic.test \
+ delegates/anonymous-initializer.test \
delegates/casting.vala \
delegates/compatible.vala \
delegates/delegate_only.vala \
diff --git a/tests/delegates/anonymous-initializer.test b/tests/delegates/anonymous-initializer.test
new file mode 100644
index 000000000..f47ebbaeb
--- /dev/null
+++ b/tests/delegates/anonymous-initializer.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+/*
+ * 11.18-11.20: error: syntax error, following expression/statement delimiter `)' missing
+ * void f (delegate(int=123) => int y) {
+ * ^^^
+ */
+
+void main () {
+ f (t);
+}
+
+void f (delegate(int=123) => int y) {
+ y (1);
+}
+
+int t (int a) {
+ return a;
+}
diff --git a/tests/delegates/anonymous-throws.test b/tests/delegates/anonymous-throws.test
new file mode 100644
index 000000000..ff11a805d
--- /dev/null
+++ b/tests/delegates/anonymous-throws.test
@@ -0,0 +1,21 @@
+Invalid Code
+
+/*
+ * 11.30-11.30: error: syntax error, following expression/statement delimiter `)' missing
+ * void f (delegate(int) => int y throws Error) {
+ * ^
+ */
+
+void main () {
+ f (t);
+}
+
+void f (delegate(int) => int y throws Error) {
+ try {
+ y (1);
+ } catch {}
+}
+
+int t (int a) throws Error {
+ return a;
+}
diff --git a/tests/delegates/anonymous-variadic.test b/tests/delegates/anonymous-variadic.test
new file mode 100644
index 000000000..fabd3a422
--- /dev/null
+++ b/tests/delegates/anonymous-variadic.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+/*
+ * 11.23-11.25: error: syntax error, expected identifier
+ * void f (delegate(int, ...) => int y) {
+ * ^^^
+ */
+
+void main () {
+ f (t);
+}
+
+void f (delegate(int, ...) => int y) {
+ y (1);
+}
+
+int t (int a, ...) {
+ return a;
+}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 5412bf29d..72bab341d 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3750,13 +3750,6 @@ public class Vala.Parser : CodeVisitor {
}
expect (TokenType.CLOSE_PARENS);
- DataType error_type = null;
- if (accept (TokenType.THROWS)) {
- do {
- error_type = parse_type (true, false);
- } while (accept (TokenType.COMMA));
- }
-
expect (TokenType.LAMBDA);
var type = parse_type (true, false);
@@ -3772,10 +3765,6 @@ public class Vala.Parser : CodeVisitor {
d.add_parameter (param);
}
- if (error_type != null) {
- d.add_error_type (error_type);
- }
-
parent.add_delegate (d);
return new DelegateType (d);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]