[vala/0.40] vala: Report error for async creation expression without yield
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Report error for async creation expression without yield
- Date: Mon, 18 Nov 2019 13:14:19 +0000 (UTC)
commit 2d57c8ddc910217f34c95d4d92063afb052d3277
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Nov 14 14:53:04 2019 +0100
vala: Report error for async creation expression without yield
tests/Makefile.am | 1 +
tests/asynchronous/creation-missing-yield.test | 10 ++++++++++
vala/valaobjectcreationexpression.vala | 5 +++++
3 files changed, 16 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 935aac999..2dca4e3e6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -434,6 +434,7 @@ TESTS = \
asynchronous/bug792942.vala \
asynchronous/bug793158.vala \
asynchronous/catch-in-finally.vala \
+ asynchronous/creation-missing-yield.test \
asynchronous/closures.vala \
asynchronous/generator.vala \
asynchronous/result-pos.vala \
diff --git a/tests/asynchronous/creation-missing-yield.test b/tests/asynchronous/creation-missing-yield.test
new file mode 100644
index 000000000..0fe234a6e
--- /dev/null
+++ b/tests/asynchronous/creation-missing-yield.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo {
+ public async Foo () {
+ }
+}
+
+void main () {
+ var foo = new Foo ();
+}
diff --git a/vala/valaobjectcreationexpression.vala b/vala/valaobjectcreationexpression.vala
index aa387fc37..a54291925 100644
--- a/vala/valaobjectcreationexpression.vala
+++ b/vala/valaobjectcreationexpression.vala
@@ -367,6 +367,11 @@ public class Vala.ObjectCreationExpression : Expression {
error = true;
Report.error (source_reference, "yield expression not available
outside async method");
}
+ } else if (m is CreationMethod) {
+ if (m.coroutine) {
+ error = true;
+ Report.error (source_reference, "missing `yield' before async
creation expression");
+ }
}
// FIXME partial code duplication of MethodCall.check
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]