[Mono-bugs] [Bug 76948][Nor] New - closures don't capture local vars correctly

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Dec 8 15:39:29 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 lupus at ximian.com.

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

--- shadow/76948	2005-12-08 15:39:29.000000000 -0500
+++ shadow/76948.tmp.16204	2005-12-08 15:39:29.000000000 -0500
@@ -0,0 +1,39 @@
+Bug#: 76948
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: lupus at ximian.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: closures don't capture local vars correctly
+
+using System;
+
+delegate void Do ();
+
+class T {
+        static void doit (int v) {
+                Console.WriteLine (v);
+        }
+        static void Main () {
+                Do[] arr = new Do [5];
+                for (int i = 0; i < 5; ++i) {
+                        arr [i] = delegate {doit (i);};
+                }
+                for (int i = 0; i < 5; ++i) {
+                        arr [i] ();
+                }
+        }
+
+}
+
+The program should print 0, 1, 2, .., but it always prints 5.


More information about the mono-bugs mailing list