[Mono-bugs] [Bug 378189] New: gmcs requires void-returning invocation in lambda expression

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 8 19:33:01 EDT 2008


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


           Summary: gmcs requires void-returning invocation in lambda
                    expression
           Product: Mono: Compilers
           Version: SVN
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: cmarshall at pacificbiosciences.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


I can't think up a better summary. This code fails to compile:

>>>>
using System;
using System.Collections;
using System.Collections.Generic;

public static class ext
{
        static public void Apply<T>(IEnumerable<T> a, Action<T> fn)
        {
                foreach (T ai in a)
                        fn(ai);
        }
}

public class action
{
        public static void Main(string[] argv)
        {
                ArrayList list = new ArrayList();
                ext.Apply(argv, str => list.Add(str));
        }
}
<<<<

Failing with:

action.cs(19,21): error CS1502: The best overloaded method match for
`ext.Apply<string>(System.Collections.Generic.IEnumerable<string>,
System.Action<string>)' has some invalid arguments
action.cs(7,28): (Location of the symbol related to previous error)
action.cs(19,21): error CS1503: Argument 2: Cannot convert type `lambda
expression' to `System.Action<string>'
Compilation failed: 2 error(s), 0 warnings

It looks like it was this change:
http://anonsvn.mono-project.com/viewcvs/trunk/mcs/mcs/lambda.cs?rev=99156&r1=98957&r2=99156

..which confuses me. Why can't an invocation that returns a non-void type be
used here?


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