[vala] Do not allow .begin() and .end() in yield statement



commit 96f0532cc503085b902c7a43a29b622be4a5b1a9
Author: Luca Bruno <lethalman88 gmail com>
Date:   Fri Jun 25 23:06:00 2010 +0200

    Do not allow .begin() and .end() in yield statement
    
    Fixes bug 622707.

 vala/valamethodcall.vala |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 79b7ecf..2684327 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -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));
 				}
 			}
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]