[Mono-bugs] [Bug 74809][Maj] Changed - anonymous methods and iterators are not working

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jul 7 16:16:39 EDT 2005


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 danw at novell.com.

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

--- shadow/74809	2005-06-08 14:40:58.000000000 -0400
+++ shadow/74809.tmp.8721	2005-07-07 16:16:39.000000000 -0400
@@ -1,13 +1,13 @@
 Bug#: 74809
 Product: Mono: Compilers
 Version: unspecified
 OS: unknown
 OS Details: 
-Status: RESOLVED   
-Resolution: FIXED
+Status: REOPENED   
+Resolution: 
 Severity: Unknown
 Priority: Major
 Component: C#
 AssignedTo: martin at ximian.com                            
 ReportedBy: martin at ximian.com               
 QAContact: mono-bugs at ximian.com
@@ -70,6 +70,66 @@
 ------- Additional Comments From martin at ximian.com  2005-05-17 11:18 -------
 Yeah, I know.  Thought this'd be a nice chance to learn the anonymous
 methods framework :-)
 
 ------- Additional Comments From martin at ximian.com  2005-06-08 14:40 -------
 Fixed in SVN with the big Iterators rewrite :-)
+
+------- Additional Comments From danw at novell.com  2005-07-07 16:16 -------
+We still generate invalid code in some cases. Eg:
+
+	using System;
+
+	public class Foo {
+
+		public static void Main ()
+		{
+			new Foo (new object[] { "foo" });
+		}
+
+		public Foo (object[] array) : this (array, array[0]) {}
+
+		public Foo (object[] array, object context)
+		{
+			if (array.GetType().IsArray)
+				Console.WriteLine ("ok! array is correct type");
+			else
+				Console.WriteLine ("boo! array is of type {0}", array.GetType ());
+
+			if (array[0] == context)
+				Console.WriteLine ("ok! array[0] == context!");
+			else
+				Console.WriteLine ("boo! array[0] != context!");
+
+			foreach (char ch in "123") {
+				DoSomething += delegate (object obj, EventArgs args) {
+					Console.WriteLine ("{0}:{1}:{2}", ch, array[0], context);
+				};
+			}
+		}
+
+		public event EventHandler DoSomething;
+	}
+
+Compiling this with mcs and running it gives:
+
+        boo! array is of type Foo+<>AnonHelp<1>
+        boo! array[0] != context!
+
+Compiling it with csc gives:
+
+        ok! array is correct type
+        ok! array[0] == context!
+
+Furthermore, if you remove the constructor chaining and change
+it to:
+
+		public Foo (object[] array)
+		{
+			object context = array[0];
+
+			if (array.GetType().IsArray)
+		...
+
+then mcs gets stuck in an infinite loop compiling it.
+
+


More information about the mono-bugs mailing list