]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Report error for async creation expression without yield
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 14 Nov 2019 13:53:04 +0000 (14:53 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 18 Nov 2019 08:33:35 +0000 (09:33 +0100)
tests/Makefile.am
tests/asynchronous/creation-missing-yield.test [new file with mode: 0644]
vala/valaobjectcreationexpression.vala

index f3bd8e2c2a9d93730f481cb7e549bd761a7ca9c6..f049e7778d171a02db19f8eac7631f5f9db7d900 100644 (file)
@@ -479,6 +479,7 @@ TESTS = \
        asynchronous/bug793158.vala \
        asynchronous/catch-error-scope.vala \
        asynchronous/catch-in-finally.vala \
+       asynchronous/creation-missing-yield.test \
        asynchronous/closures.vala \
        asynchronous/finish-name.vala \
        asynchronous/generator.vala \
diff --git a/tests/asynchronous/creation-missing-yield.test b/tests/asynchronous/creation-missing-yield.test
new file mode 100644 (file)
index 0000000..0fe234a
--- /dev/null
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo {
+       public async Foo () {
+       }
+}
+
+void main () {
+       var foo = new Foo ();
+}
index 5f4fce753eadfe4ea92a84d8aab16b5ea016004e..10e19574261bc08928bdce943c8ef7ea60345b3b 100644 (file)
@@ -365,6 +365,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