[Mono-bugs] [Bug 61907][Wis] New - Iterator methods can have return types other than IEnumerable and IEnumerator

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 24 Jul 2004 10:41:50 -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 sourcejedi@phonecoop.coop.

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

--- shadow/61907	2004-07-24 10:41:50.000000000 -0400
+++ shadow/61907.tmp.6375	2004-07-24 10:41:50.000000000 -0400
@@ -0,0 +1,81 @@
+Bug#: 61907
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sourcejedi@phonecoop.coop               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Iterator methods can have return types other than  IEnumerable and IEnumerator
+
+Description of Problem:
+
+You can use return values other than IEnumerator or IEnumerable - so long
+as they descend from those interfaces.  This can cause problems, and is
+contrary to the C# 2.0 spec on the microsoft website
+(http://download.microsoft.com/download/8/1/6/81682478-4018-48fe-9e5e-f87a44af3db9/SpecificationVer2.doc)
+
+Steps to reproduce the problem:
+1.
+
+// Test.cs
+using System;
+using System.Collections;
+
+public interface IEnumerator2 : IEnumerator 
+{
+        object Current {
+                get;
+        }
+}
+
+public class Test {
+        public static void Main (string[] args)
+        {
+                IEnumerator2 e = Enumerate ();
+                while (e.MoveNext ()) {
+                        object value = e.current;
+                }
+        }
+
+        public static IEnumerator2 Enumerate () 
+        {
+                yield return "Hello world!";
+        }
+}
+
+2. 
+
+mcs -2 --debug Test.cs
+
+3.
+
+mono --debug Test.exe
+
+Actual Results:
+
+a null pointer exception, apparently on the line after "object value =
+e.Current;".
+
+Expected Results:
+
+N/A
+
+How often does this happen? 
+
+Always on mono 1.0
+
+Additional Information:
+
+The C# 2.0 spec might not yet been finalized, but I'd be suprised if it
+changed on this issue - you really shouldn't be allowed to use your own
+IEnumerator / IEnumerable interfaces (or even classes) for iterator method
+return types.