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 [EMAIL PROTECTED] http://bugzilla.ximian.com/show_bug.cgi?id=80632 --- shadow/80632 2007-01-26 05:35:48.000000000 -0500 +++ shadow/80632.tmp.14470 2007-01-26 05:35:48.000000000 -0500 @@ -0,0 +1,78 @@ +Bug#: 80632 +Product: Mono: Compilers +Version: 1.2 +OS: GNU/Linux [Other] +OS Details: +Status: NEW +Resolution: +Severity: +Priority: Normal +Component: C# +AssignedTo: [EMAIL PROTECTED] +ReportedBy: [EMAIL PROTECTED] +QAContact: [EMAIL PROTECTED] +TargetMilestone: --- +URL: +Cc: +Summary: Cannot compile foreach over generic collections + +Description of Problem: +In certain cases, gmcs isn't able to compile a foreach enumeration over a +generic collection, emitting confusing messages regarding ambiguity of +GetEnumerator(). The messages can be both warnings and errors. An example +of both cases follows (I considered these related, so posting as a single +bug report). + +Steps to reproduce the problem: +1. Download and unpack http://www.itu.dk/research/c5/Release1.0/C5.bin.zip +2. Create ambiguous-enumerable-warning.cs: + +using System.Collections.Generic; +class X{static void Main(){ +IDictionary<int,int> dict = new Dictionary<int,int>(); +foreach (KeyValuePair<int,int> pair in dict) { +System.Console.WriteLine(pair.Key); +} +}} + +3. Create ambiguous-enumerable-error.cs: + +public class A: C5.ArrayList<int> {} +class X{static void Main(){ +A x = new A(); +foreach (int i in x) { +} +}} + +4. gmcs -warnaserror ambiguous-enumerable-warning.cs +5. gmcs /r:C5.dll ambiguous-enumerable-error.cs + +Actual Results: +ambiguous-enumerable-warning.cs(4,1): error CS0278: +`System.Collections.Generic.IDictionary<int,int>' contains ambiguous +implementation of `enumerable' pattern. Method +`System.Collections.IEnumerable.GetEnumerator()' is ambiguous with method +`System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<int,int>>.GetEnumerator()' +/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous +error) +/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous +error) +Compilation failed: 1 error(s), 0 warnings + +ambiguous-enumerable-error.cs(5,1): error CS1640: foreach statement cannot +operate on variables of type `A' because it contains multiple +implementation of `C5.ArrayBase<int>.GetEnumerator()'. Try casting to a +specific implementation +ambiguous-enumerable-error.cs(1,14): (Location of the symbol related to +previous error) +Compilation failed: 1 error(s), 0 warnings + +Expected Results: +Two successes. + +How often does this happen? +100% + +Additional Information: +Reproduces with mono 1.2.2.1 +The test cases compile fine with both csc and mono 1.1.13.6. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
