[Mono-bugs] [Bug 428191] New: Compiler crashes when using nested lambdas within generic method

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Sep 21 14:02:41 EDT 2008


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


           Summary: Compiler crashes when using nested lambdas within
                    generic method
           Product: Mono: Compilers
           Version: SVN
          Platform: x86-64
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mono at e-tobi.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


This piece of code:

public class MainProgram
{
    public static void Main()
    {
    }

    public void AnyMethod<T>()
    {
        Action<string> outerAction = outerActionParam =>
        {
            Action<string> innerAction = innerActionParam =>
innerActionParam.Contains(outerActionParam);
        };
    }
}

lets the compiler crash:

Registry.cs(13,28): warning CS0219: The variable `innerAction' is assigned but
its value is never used
Registry.cs(11,24): warning CS0219: The variable `outerAction' is assigned but
its value is never used
Exception caught by the compiler while emitting:
   Block that caused the problem begin at: Registry.cs(12,9):
System.NullReferenceException: Object reference not set to an instance of an
object
Internal compiler error at Registry.cs(11,55):: exception caught while emitting
MethodBuilder [MainProgram::<AnyMethod>m__0]

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at Mono.CSharp.AnonymousMethodStorey.EmitHoistedVariables
(Mono.CSharp.EmitContext ec) [0x00044] in
/home/tobias/sandbox/x/mcs/mcs/anonymous.cs:269 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x0000b] in
/home/tobias/sandbox/x/mcs/mcs/statement.cs:2489 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in
/home/tobias/sandbox/x/mcs/mcs/statement.cs:2919 
  at Mono.CSharp.EmitContext.EmitResolvedTopBlock (Mono.CSharp.ToplevelBlock
block, Boolean unreachable) [0x00006] in
/home/tobias/sandbox/x/mcs/mcs/codegen.cs:847 
  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00037] in
/home/tobias/sandbox/x/mcs/mcs/codegen.cs:752 

This only happens, if AnyMethod() is generic and only with this kind of
"nested" lambdas.


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