Bug 45774 - Wrong scopes in .mdb in case of foreach loop
Summary: Wrong scopes in .mdb in case of foreach loop
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: High normal
Target Milestone: 4.8.0 (C9)
Assignee: Marek Safar
Depends on:
Reported: 2016-10-21 04:52 UTC by David Karlaš
Modified: 2017-01-03 11:40 UTC (History)
2 users (show)

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


Description David Karlaš 2016-10-21 04:52:06 UTC
This method: https://github.com/xamarin/md-addins/blob/9a381a845694bffc417acd307a22ad43bc3fcc9f/MonoDevelop.MonoDroid/Xamarin.AndroidDesigner/Xamarin.AndroidDesigner/LayoutInfo.cs#L198-L208
Produces this mdbdump.exe output: https://gist.github.com/DavidKarlas/9c4c970c2f8ba8be6302fda8575e9895
It seems to me that "problem" variable should have scope_ref="3" and "itemData" variable should have scope_ref="4"

This is maybe related to missing il_index="3"?
Comment 1 Marek Safar 2016-10-21 15:46:35 UTC
This is by design scope_ref="1" means scope with index 2
Comment 2 David Karlaš 2016-10-23 04:30:22 UTC
I'm now confident this is mcs.exe bug. I have new sample: https://gist.github.com/DavidKarlas/b3e2cef574d390253bee554c2e3c55a6
"item2" variable is totally off. Either with index=4 or index=5. Also there is way too many scopes.
Comment 3 Marek Safar 2016-11-04 15:08:41 UTC
Fixed in master and Mono 4.8
Comment 5 David Karlaš 2016-12-31 11:59:32 UTC
Place breakpoints on all Console.WriteLine() lines and inspect values of item1 and item2 are correct.

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.

Create a new report for Bug 45774 on Developer Community or GitHub if you have new information to add and do not yet see a matching report.

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

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.

Related Links: