[Mono-bugs] [Bug 431255] New: [gmcs] IOE within compiler when compiling "nested" lambda expressions.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Oct 1 09:24:03 EDT 2008


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


           Summary: [gmcs] IOE within compiler when compiling "nested"
                    lambda expressions.
           Product: Mono: Compilers
           Version: SVN
          Platform: x86-64
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jpryor at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


gmcs dies with an InvalidOperationException when compiling code that has a
lambda expression "nested" 3 or more levels deep.

Take the following source:

  using System;

  static class DelegateRocks {
    public static Func<T1, Func<T2, Action<T3>>>
      Curry<T1, T2, T3> (this Action<T1, T2, T3> self)
    {
      return value1 => value2 => value3 => self (value1, value2, value3);
    }
  }

  class Test {
    static void Main ()
    {
    }
  }

Compile it:

  gmcs bug.cs

Expected output:

No error.

Actual output:

Exception caught by the compiler while emitting:
   Block that caused the problem begin at: bnc.cs(7,34):
System.InvalidOperationException: Operation is not valid due to the current
state of the object
Internal compiler error at bnc.cs(7,31):: exception caught while emitting
MethodBuilder [<Curry>c__AnonStorey1`3::<>m__1]

Unhandled Exception: System.InvalidOperationException: Operation is not valid
due to the current state of the object
  at Mono.CSharp.DeclSpace.get_CurrentTypeParameters () [0x00000] 
  at Mono.CSharp.AnonymousMethodStorey.EmitHoistedVariables
(Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.EmitResolvedTopBlock (Mono.CSharp.ToplevelBlock
block, Boolean unreachable) [0x00000] 
  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00000] 


It works fine if there are only 2 nested levels:

    public static Func<T1, Action<T2>>
      Curry<T1, T2> (this Action<T1, T2> self)
    {
      return value1 => value2 => self (value1, value2);
    }


Basic idea "borrowed" from:

http://blogs.msdn.com/wesdyer/archive/2007/01/29/currying-and-partial-function-application.aspx


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