Bugzilla – Bug 392448
gmcs issue with lambda expression passed as delegates
Last modified: 2008-07-08 15:02:40 UTC
Repro: -- using System; using System.Collections; class Test { public static IList Foo (Action<IList> action) { ArrayList l = new ArrayList (); action (l); return l; } public static IList Populator (IList list, IEnumerable items) { foreach (object item in items) list.Add (item); return list; } public static void Main (string [] args) { var list = Foo (l => Populator (l, args)); foreach (object item in list) Console.WriteLine (item); } } -- Fails with: [mono] ~/Desktop @ gmcs test.cs test.cs(22,28): error CS1502: The best overloaded method match for `Test.Foo(System.Action<System.Collections.IList>)' has some invalid arguments test.cs(5,29): (Location of the symbol related to previous error) test.cs(22,28): error CS1503: Argument 1: Cannot convert type `lambda expression' to `System.Action<System.Collections.IList>' test.cs(24,17): error CS1579: foreach statement cannot operate on variables of type `object' because it does not contain a definition for `GetEnumerator' or is not accessible That should compile and print to stdout all arguments passed to the executable.
*** This bug has been marked as a duplicate of bug 378189 ***