[Mono-bugs] [Bug 79840][Maj] New - Anonymous methods not capturing local variables

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Nov 5 19:57:23 EST 2006


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 eskil at letterboxes.org.

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

--- shadow/79840	2006-11-05 19:57:23.000000000 -0500
+++ shadow/79840.tmp.32679	2006-11-05 19:57:23.000000000 -0500
@@ -0,0 +1,67 @@
+Bug#: 79840
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: eskil at letterboxes.org               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Anonymous methods not capturing local variables
+
+Description of Problem:
+On Mono 1.2 RC, anonymous methods are not capturing local variables
+correct. Test case:
+
+using System;
+public class Test
+{
+    public delegate void TestDelegate();
+    public static void Main(string[] args)
+    {
+        TestDelegate d = null;
+        for (int i = 1; i <= 5; i++)
+        {
+            int k = i;
+            TestDelegate temp = delegate
+            {
+                Console.WriteLine(k);
+            };
+            d += temp;
+        }
+        d();
+    }
+}
+
+Steps to reproduce the problem:
+1. 
+2. 
+3. 
+
+Actual Results:
+Test case output:
+5
+5
+5
+5
+5
+
+Expected Results:
+Test case output:
+1
+2
+3
+4
+5
+
+How often does this happen? 
+
+
+Additional Information:


More information about the mono-bugs mailing list