]> 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>
Thu, 14 Nov 2019 13:53:04 +0000 (14:53 +0100)
tests/Makefile.am
tests/asynchronous/creation-missing-yield.test [new file with mode: 0644]
vala/valaobjectcreationexpression.vala

index 2bbd134b9b3d5eaaf7287415ff47027901c92717..bc79845a7ed0d2fa2032d5098c869eab2c11fbec 100644 (file)
@@ -496,6 +496,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 978885808d35cafc9b5c1981e3de3dfbb38c7b3b..caf9414a6e9a5bdffa2ab584d8a3721672c54821 100644 (file)
@@ -366,6 +366,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