Skip to content

Commit

Permalink
vala: Report error for async creation expression without yield
Browse files Browse the repository at this point in the history
  • Loading branch information
ricotz committed Nov 15, 2019
1 parent ab6fbac commit 94bd762
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Makefile.am
Expand Up @@ -486,6 +486,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 \
Expand Down
10 changes: 10 additions & 0 deletions tests/asynchronous/creation-missing-yield.test
@@ -0,0 +1,10 @@
Invalid Code

class Foo {
public async Foo () {
}
}

void main () {
var foo = new Foo ();
}
5 changes: 5 additions & 0 deletions vala/valaobjectcreationexpression.vala
Expand Up @@ -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
Expand Down

0 comments on commit 94bd762

Please sign in to comment.