Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
The attached file, when compiled under the Mono C# compiler version 188.8.131.52, produces the following output:
While the result indeed mimics .NET's behaviour it is clear that there was a design error (at least according to people on SO), since it is expected for closures in that case to enclose on _different_ variables. Microsoft has recently changed the implementation of foreach and the behaviour is no longer perplexing in VS11.
I do understand that patching foreach might break some backward compatibility in theory, but in practice I can't honestly find a usecase for this (e.g.: when you need all of your closures to be enclosed on one variable with the last value).
Please pardon my English as I am not a native speaker.
Created attachment 1494 [details]
Fixed in master