Bug 6469 - Closure error for anonomous delegate in nested iterator; behavior differs from csc
Summary: Closure error for anonomous delegate in nested iterator; behavior differs fro...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-08-08 12:13 UTC by cod3monk3y
Modified: 2012-08-09 09:53 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case. To run, call new InnerYield().Run() (4.64 KB, text/plain)
2012-08-08 12:13 UTC, cod3monk3y
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description cod3monk3y 2012-08-08 12:13:18 UTC
Created attachment 2329 [details]
Test case. To run, call new InnerYield().Run()

In the attached file, the anonymous delegate (in the method Outer()) in the double_iterator() test is always capturing the 2nd instance of Foo, rather than the instance created during the iteration of the loop. This behavior differs from csc. The output of InnerYield.Run() for the different platforms is:


PC (csc):

direct_call
delegate update Foo(id=0)
delegate update Foo(id=1)
1 1
PASS
single_iterator
delegate update Foo(id=0)
delegate update Foo(id=1)
1 1
PASS
double_iterator
delegate update Foo(id=0)
delegate update Foo(id=1)
1 1
PASS


MONO (mcs):

direct_call
delegate update Foo(id=0)
delegate update Foo(id=1)
1 1 
PASS
single_iterator
delegate update Foo(id=0)
delegate update Foo(id=1)
1 1 
PASS
double_iterator
delegate update Foo(id=1)
delegate update Foo(id=1)
0 2 
FAIL
Comment 1 Marek Safar 2012-08-09 03:50:06 UTC
This is C#5 change implemented in mono 2.11
Comment 2 cod3monk3y 2012-08-09 09:53:47 UTC
OK. I am running MonoDevelop 3.0.3.5 with Mono 2.10.9. Will look for this fix when MD is updated with Mono 2.11. Thanks!