Bug 6687 - mcs does not properly handle anonymous methods
Summary: mcs does not properly handle anonymous methods
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-24 20:28 UTC by Martin Potter
Modified: 2012-09-04 09:59 UTC (History)
1 user (show)

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


Attachments
Compiler bug handling anonymous methods (2.25 KB, application/octet-stream)
2012-08-24 20:28 UTC, Martin Potter
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 Martin Potter 2012-08-24 20:28:29 UTC
Created attachment 2407 [details]
Compiler bug handling anonymous methods

Compiling our application with mcs from 2.11.3 succeeds, but results in some invalid generated code which subsequently crashes the application when run. I have attached a program that isolates the method that is causing the crash in our application. Reflecting over the compiled sample program with Reflector, the generated code appears to be incorrect. Logging out in the program produces the following:

B.Parse (before AddRange): m_c is a CompilerBug.C
C.Split: c is a CompilerBug.C
B.Parse (in Where): m_c is a System.Collections.Generic.List`1[CompilerBug.E]

The third line show that the variable captured in the anonymous method is not correct. To reproduce, compile the attached program with mcs from mono 2.11.3 (I believe this is still an issue in master) and run. The program will throw an exception when run (which should not occur).
Comment 1 Marek Safar 2012-09-04 09:59:51 UTC
Fixed in master