[Mono-bugs] [Bug 76620][Wis] New - mcs does not properly detect variable name conflicts when using anonymous methods

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Nov 2 16:27:16 EST 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 eric at extremeboredom.net.

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

--- shadow/76620	2005-11-02 16:27:16.000000000 -0500
+++ shadow/76620.tmp.22973	2005-11-02 16:27:16.000000000 -0500
@@ -0,0 +1,49 @@
+Bug#: 76620
+Product: Mono: Compilers
+Version: 1.0
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: eric at extremeboredom.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs does not properly detect variable name conflicts when using anonymous methods
+
+The following code should not compile:
+
+public class AnonTest
+{
+	public static void Main ()
+	{
+		new AnonTest ();	
+	}
+
+	delegate void MooEventHandler (string moo);
+	event MooEventHandler bleh;
+	
+	public AnonTest ()
+	{
+		AddEvent ("moo");
+	}
+
+	void AddEvent (string moo)
+	{
+		bleh += delegate (string moo) { 
+			System.Console.WriteLine (moo);
+		};
+	}
+}
+
+On .NET 2.0 final, the following error is generated:
+
+test.cs(20,21): error CS0136: A local variable named 'moo' cannot be
+declared in
+        this scope because it would give a different meaning to 'moo', which is
+        already used in a 'parent or current' scope to denote something else


More information about the mono-bugs mailing list