[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


           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);

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

                        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:


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

Expected Results:


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