https://bugzilla.novell.com/show_bug.cgi?id=394347


           Summary: Anonymous delegates do strange things.
           Product: Mono: Compilers
           Version: 1.2.6
          Platform: x86
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          Found By: ---


Description of Problem:
Wrong compilation of anonymous delegates

Steps to reproduce the problem:
1. 
using System;
using System.Collections.Generic;
using System.Text;

delegate object FactoryDelegate();

public class C
{
        Dictionary<string, FactoryDelegate> T =
                new Dictionary<string, FactoryDelegate>();

        public void X()
        {
                T["ABC"] = delegate()
                {
                        Console.WriteLine ( "A" );
                        return "Return";
                };
        }

        static void Main ( String[] strArgs )
        {
                var o = new C();
                o.X();

                Console.WriteLine ( "B" );

                Console.WriteLine ( o.T [ "ABC" ]());
        }
}

2. 
[EMAIL PROTECTED]:~/Desktop$ gmcs -langversion:linq test.cs 
test.cs(16,33): warning CS0162: Unreachable code detected
Compilation succeeded - 1 warning(s)
[EMAIL PROTECTED]:~/Desktop$ mono test.exe
B
Return

Actual Results:
Wrong output of compiler, wrong output of executable


Expected Results:

c:\Users\mbrenn\Desktop>csc test.cs
Microsoft (R) Visual C# 2008 Compiler Version 3.5.21022.8
, für Microsoft (R) .NET Framework Version 3.5
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.


c:\Users\mbrenn\Desktop>test
B
A
Return

How often does this happen? 

Everytime

Additional Information:


Also on Gentoo with Mono 1.9.0 (selfcompiled). 

Sry for short bug report, but this marvelous bugreporter has eaten my former
tries twice.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to