[Mono-bugs] [Bug 54902][Wis] Changed - Invalid IL generated for iterator

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 27 Feb 2004 02:16:00 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by miguel@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=54902

--- shadow/54902	2004-02-26 12:29:06.000000000 -0500
+++ shadow/54902.tmp.3123	2004-02-27 02:16:00.000000000 -0500
@@ -2,22 +2,22 @@
 Product: Mono/Compilers
 Version: unspecified
 OS: other
 OS Details: 
 Status: NEW   
 Resolution: 
-Severity: 
+Severity: Unknown
 Priority: Wishlist
 Component: C#
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: sourcejedi@phonecoop.coop               
 QAContact: mono-bugs@ximian.com
 TargetMilestone: ---
 URL: 
 Cc: 
-Summary: Iterators cannot be used inside operators or (getter) property accessors
+Summary: Invalid IL generated for iterator
 
 Description of Problem: 
  
 If you use iterators - ie the yield keyword - inside an operator or a 
 "get" property accessor - the compiler fails with an error that suggests 
 it should not fail. 
@@ -65,6 +65,43 @@
  
 Compilation succeeded 
  
 How often does this happen?  
  
 Always
+
+------- Additional Comments From miguel@ximian.com  2004-02-27 02:16 -------
+A more complete example;  Fixed most of the issues, but the code
+generated is invalid IL now:
+
+using System;
+using System.Collections; 
+ 
+public class X : IEnumerable { 
+        public static IEnumerable operator + (X a, X b) 
+        { 
+		yield return -1;
+		foreach (object o in a)
+			yield return o;
+		yield return -2;
+		foreach (object o in b)
+			yield return o;
+		yield return -3;
+
+        } 
+	public IEnumerator GetEnumerator ()
+	{
+		yield return 1;
+	}
+} 
+ 
+class D {
+static void Main ()
+{
+	X a = new X ();
+	X b = new X ();
+	foreach (object o in (a + b)){
+		Console.WriteLine ("-> " + o);
+	}
+}
+}
+