[Mono-bugs] [Bug 664205] New: Delegates created from nested lambda expressions sometimes have no target

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Jan 13 05:01:47 EST 2011



           Summary: Delegates created from nested lambda expressions
                    sometimes have no target
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.8.x
          Platform: x86
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Core
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: timeslip at users.sourceforge.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: No

Created an attachment (id=408165)
 --> (http://bugzilla.novell.com/attachment.cgi?id=408165)
test case

Description of Problem:
When using a nested LambdaExpression that doesn't use its implicit Closure
argument as an argument to a call that expects a Delegate type, the passed
delegate has no target but the generated method still has a first argument of
CompilerServices.Closure. This results in a mismatch in the expected and
supplied number of arguments when invoking the delegate. Either the delegate
should have its closure target, or the generated method shouldn't expect one.

Steps to reproduce the problem:
1. Compile and run the attached test case

Actual Results:
A TargetParameterCountException is thrown at the func.DynamicInvoke()

Expected Results:
Output '5'.

How often does this happen? 

Additional Information:
Running on .net outputs 5 as expected.

If the test case is modified such that the Closure is referenced in the nested
lambda. (e.g. defining a local variable in the outer lambda, and returning it
from the nested lambda,) then it will work correctly.

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