[Mono-bugs] [Bug 56127][Nor] New - Iterator compiles to invalid IL

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 28 Mar 2004 04:24:19 -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 sourcejedi@phonecoop.coop.

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

--- shadow/56127	2004-03-28 04:24:19.000000000 -0500
+++ shadow/56127.tmp.16117	2004-03-28 04:24:19.000000000 -0500
@@ -0,0 +1,75 @@
+Bug#: 56127
+Product: Mono: Compilers
+Version: unspecified
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sourcejedi@phonecoop.coop               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Iterator compiles to invalid IL
+
+Please fill in this template when reporting a bug, unless you know what 
+you are doing. 
+Description of Problem: 
+ 
+ 
+Steps to reproduce the problem: 
+ 
+1. Create test.cs: 
+ 
+//test.cs starts 
+using System.Collections; 
+ 
+public class Test { 
+	public static void Main (string[] args) 
+	{ 
+		foreach (object o in Iterate ()) 
+			/*do nothing*/; 
+	} 
+ 
+	static IEnumerable Iterate () 
+	{ 
+		while (true) { 
+			if (Condition) 
+				break; 
+		} 
+ 
+		yield break;	//yield return fails in the same way 
+	} 
+ 
+	static bool Condition { 
+		get { return true; } 
+	} 
+} 
+//test.cs ends 
+ 
+2. Compile test.cs: 
+ 
+mcs /2 test.cs 
+ 
+(the /2 is not necessary, though I think it should be) 
+ 
+3. Run test.exe 
+ 
+mono test.exe 
+ 
+Actual Results: 
+ 
+** ERROR **: Invalid IL code at IL002d in 
+__Proxy_0:System.IEnumerator.MoveNext (): IL_002d: ret 
+ 
+Expected Results: 
+ 
+(program runs and finishes without outputing anything) 
+ 
+How often does this happen?  
+ 
+every time