From: Rico Tzschichholz Date: Thu, 14 Nov 2019 13:53:04 +0000 (+0100) Subject: vala: Report error for async creation expression without yield X-Git-Tag: 0.44.11~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=515744e680aed4cacbb5af2c78425f43ae6bfc27;p=thirdparty%2Fvala.git vala: Report error for async creation expression without yield --- diff --git a/tests/Makefile.am b/tests/Makefile.am index f3bd8e2c2..f049e7778 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 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 5f4fce753..10e195742 100644 --- a/vala/valaobjectcreationexpression.vala +++ b/vala/valaobjectcreationexpression.vala @@ -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