]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Do not allow .begin() and .end() in yield statement
authorLuca Bruno <lethalman88@gmail.com>
Fri, 25 Jun 2010 21:06:00 +0000 (23:06 +0200)
committerJürg Billeter <j@bitron.ch>
Mon, 28 Jun 2010 21:51:00 +0000 (23:51 +0200)
Fixes bug 622707.

vala/valamethodcall.vala

index 79b7ecf1320eecfd39d58f95639e22c44bb11108..26843276271936b6cdc265fcf3d28248ff6d72d3 100644 (file)
@@ -276,16 +276,21 @@ public class Vala.MethodCall : Expression {
 
                if (mtype is MethodType) {
                        var m = ((MethodType) mtype).method_symbol;
-                       if (m != null && m.coroutine && !is_yield_expression) {
-                               // begin or end call of async method
+                       if (m != null && m.coroutine) {
                                var ma = (MemberAccess) call;
-                               if (ma.member_name != "end") {
-                                       // begin (possibly implicit)
-                                       params = m.get_async_begin_parameters ();
-                                       ret_type = new VoidType ();
-                               } else {
-                                       // end
-                                       params = m.get_async_end_parameters ();
+                               if (!is_yield_expression) {
+                                       // begin or end call of async method
+                                       if (ma.member_name != "end") {
+                                               // begin (possibly implicit)
+                                               params = m.get_async_begin_parameters ();
+                                               ret_type = new VoidType ();
+                                       } else {
+                                               // end
+                                               params = m.get_async_end_parameters ();
+                                       }
+                               } else if (ma.member_name == "begin" || ma.member_name == "end") {
+                                       error = true;
+                                       Report.error (ma.source_reference, "use of `%s' not allowed in yield statement".printf (ma.member_name));
                                }
                        }