Bugzilla – Bug 318845
[PATCH] mcs generates duplicate field names for iterator code
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by jankit@novell.com 2005-08-30 03:43:13 MST ---- test case: using System; using System.Collections; class test { public IEnumerable testen (int x) { for (int i = 0;i < x; i++) if (i % 2 == 0) { int o = i; yield return o; } else { int o = i*2; yield return o; } } } compiled with gmcs and then monodis : ... <snip> .class nested private auto ansi beforefieldinit '<testen>__0' extends [mscorlib]System.Object implements [mscorlib]System.Collections.IEnumerable, class [mscorlib]System.Collections.Generic.'IEnumerable`1'<object>, [mscorlib]System.Collections.IEnumerator, [mscorlib]System.IDisposable, class [mscorlib]System.Collections.Generic.'IEnumerator`1'<object> { .field private int32 $PC .field private object $current .field assembly class test '<>THIS' .field assembly int32 '<p:x>' .field assembly int32 i .field assembly int32 o ->>>>> .field assembly int32 o ->>>>>Duplicate fields ... <snip> Compiled with csc (2.0) and ildasm'ed, ... <snip> .field /*04000004*/ public int32 '<>3__x' .field /*04000005*/ public int32 '<i>5__1' .field /*04000006*/ public int32 '<o>5__2' .field /*04000007*/ public int32 '<o>5__3' ... <snip> ilasm is not able to compile duplicate field names. ---- Additional Comments From jankit@novell.com 2005-08-30 03:44:52 MST ---- Created an attachment (id=168431) test.dll, compiled with csc (2.0) ---- Additional Comments From rharinath@novell.com 2005-08-30 06:34:47 MST ---- Created an attachment (id=168432) Proposed fix ---- Additional Comments From rharinath@novell.com 2005-08-30 06:36:05 MST ---- Here's the output after the proposed fix: .field assembly int32 '<p:x>' .field assembly int32 '<1:i>' .field assembly int32 '<2:o>' .field assembly int32 '<3:o>' ---- Additional Comments From rharinath@novell.com 2005-08-30 11:13:29 MST ---- Fixed in SVN r49131. ---- Additional Comments From rharinath@novell.com 2005-08-30 11:13:48 MST ---- . ---- Additional Comments From jankit@novell.com 2005-09-12 00:45:18 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO76009 has been marked as a duplicate of this bug. *** Imported an attachment (id=168431) Imported an attachment (id=168432) Unknown operating system unknown. Setting to default OS "Other".