[Mono-bugs] [Bug 385503] New: Compiler generated enumerator fails when iterating over empty list

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu May 1 03:08:20 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=385503


           Summary: Compiler generated enumerator fails when iterating over
                    empty list
           Product: Mono: Compilers
           Version: SVN
          Platform: Other
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: albright at wesay.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


The following program throws System.InvalidOperationException when compiled
under Mono but is fine when compiled with .Net

class Program
{
    static public IEnumerable<string> Empty
    {
        get
        {
            string[] strings = new string[] { };
            foreach (string s in strings)
            {
                yield return s;
            }
        }
    }

    static void Main()
    {
        IEnumerator<string> enumerator = Empty.GetEnumerator();
        enumerator.MoveNext();
        if (enumerator.Current == null)
        {
            Console.WriteLine("Successful");
        }
    }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list