[Mono-bugs] [Bug 45761][Nor] New - foreach fails in iterators.
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Wed, 2 Jul 2003 21:03:27 -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 miguel@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=45761
--- shadow/45761 Wed Jul 2 21:03:27 2003
+++ shadow/45761.tmp.15913 Wed Jul 2 21:03:27 2003
@@ -0,0 +1,42 @@
+Bug#: 45761
+Product: Mono/MCS
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: miguel@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: foreach fails in iterators.
+
+A couple of statements require local variables (like foreach). These local
+variables should be morphed into an instance variable of the generated
+classes to keep their state.
+
+For instance, the following program will fail with iterators:
+
+using System.Collections;
+
+class X {
+ static IEnumerable A (int [] a)
+ {
+ foreach (int b in a)
+ yield b;
+ }
+
+ static void Main ()
+ {
+ foreach (int a in A (new int [] {1, 2, 3})){
+ Console.WriteLine ("-> " + a);
+ }
+ }
+}
+
+Instead of crashing, it should print 1, 2, 3