[Mono-bugs] [Bug 436407] New: C# compiler outputs invalid code

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Oct 17 05:57:46 EDT 2008


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


           Summary: C# compiler outputs invalid code
           Product: Mono: Compilers
           Version: 2.0
          Platform: Macintosh
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Blocker
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: oliver at sturmnet.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:

Curried format function call is compiled into IL that renders a
MissingFieldException when running.

Steps to reproduce the problem:
1. Compile this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutomaticCurrying {
        class Program {
                static void Main(string[] args) {
                        Func<int, int, int> add = (x, y) => x + y;

                        var addCurriedAuto = Curry(add);
                        var add10 = addCurriedAuto(10);
                        Console.WriteLine(add10(32));

                        Func<int, string, int> weirdCalc =
                                (val, text) => val * text.Length;
                        var weirdCalcCurried = Curry(weirdCalc);
                        var weirdCalc3 = weirdCalcCurried(3);
                        Console.WriteLine(weirdCalc3("Hi"));

                        Func<int, int, int, int> multiplyAndAdd =
                                (a, b, c) => a * b + c;

                        var curriedMultiplyAndAdd = Curry(multiplyAndAdd);

                        Console.WriteLine(multiplyAndAdd(10, 3, 5));
                        Console.WriteLine(curriedMultiplyAndAdd(10)(3)(5)); //
same result

                        var multiplyBy3AndAdd = curriedMultiplyAndAdd(3);
                        Console.WriteLine(multiplyBy3AndAdd(10)(5)); // same
result again
                }

                static Func<T1, Func<T2, T3>> Curry<T1, T2, T3>(Func<T1, T2,
T3> func) {
                        return par1 => par2 => func(par1, par2);
                }

                static Func<T1, Func<T2, Func<T3, T4>>> Curry<T1, T2, T3,
T4>(Func<T1, T2, T3, T4> func) {
                        return par1 => par2 => par3 => func(par1, par2, par3);
                }

                static Func<T1, Func<T2, Func<T3, Func<T4, T5>>>> Curry<T1, T2,
T3, T4, T5>(Func<T1, T2, T3, T4, T5> func) {
                        return par1 => par2 => par3 => par4 => func(par1, par2,
par3, par4);
                }
        }
}

2. Run the compiled assembly


Actual Results:

42
6
35

Unhandled Exception: System.MissingFieldException: Field
'.<Curry>c__AnonStorey4`4.<>f__ref$3' not found.
  at AutomaticCurrying.Program.Main (System.String[] args) [0x00000] 

Expected Results:

42
6
35
35
35


How often does this happen? 

Every time

Additional Information:

I tried running the compiled assembly on Windows (MS .NET) and it gave the same
error result. The other way round, the assembly compiled by MS .NET 3.5
compiler runs on mono just fine.


-- 
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.


More information about the mono-bugs mailing list