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)

See Also:
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.

Note You need to log in before you can comment on or make changes to this bug.