[Mono-bugs] [Bug 65521][Nor] New - Inside iterator method, foreach statement emits an Invalid IL
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 8 Sep 2004 09:44:17 -0400 (EDT)
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 atsushi@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=65521
--- shadow/65521 2004-09-08 09:44:17.000000000 -0400
+++ shadow/65521.tmp.27191 2004-09-08 09:44:17.000000000 -0400
@@ -0,0 +1,51 @@
+Bug#: 65521
+Product: Mono: Compilers
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: C#
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: atsushi@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Inside iterator method, foreach statement emits an Invalid IL
+
+GMCS generates invalid IL code for iterator that contains "foreach" statement.
+
+
+using System;
+using System.Collections;
+
+public class Test
+{
+ public static void Main ()
+ {
+ foreach (object o in new Test ())
+ Console.WriteLine (o);
+ }
+
+ public IEnumerator GetEnumerator ()
+ {
+ foreach (int i in new ArrayList ())
+ yield return i;
+ }
+}
+
+Actual Results:
+** ERROR **: Invalid IL code at IL00ba in <GetEnumerator>_0:MoveNext ():
+IL_00ba: nop
+
+Expected Results:
+- MS .NET 2.0 csc compiled this example fine.
+
+How often does this happen?
+- consistently.
+
+Additional Information:
+When I replaced foreach with GetEnumerator() and MoveNext(), it worked fine.