Bug 318845 (MONO75934) - [PATCH] mcs generates duplicate field names for iterator code
Summary: [PATCH] mcs generates duplicate field names for iterator code
Status: RESOLVED FIXED
Alias: MONO75934
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 10:43 UTC by Jain Ankit
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
test.dll, compiled with csc (2.0) (4.50 KB, application/octet-stream)
2005-08-30 10:44 UTC, Thomas Wiest
Details
Proposed fix (1.25 KB, patch)
2005-08-30 13:34 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:28:59 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".