[Mono-list] type inference in nested generic lambdas goes wrong?

Jansen Bart bjansen at etro.vub.ac.be
Wed Apr 30 05:37:14 EDT 2008

Dear all,


It seems that something is going wrong with nested generic lambdas, see
the example below.

Is this a known issue? If so, is there any solution to be expected soon?

If it is a new issue, I will try to produce a simpler example and file a
bug report.

By the way, I know the code below is not doing anything useful, it is an
artifiical example to reproduce the issue.



public delegate void mapcBlock<T>(T el);

// mapc applies a function on every element of the list, the original
list is returned

public static List<T> mapc<T>(this List<T> lijst, mapcBlock<T> mpl)


lijst.ForEach((T el) => { mpl(el); });         

      return lijst;



public static void foo<T>(List<T> lijst)


            mapc(lijst, (T el) => 


                List<T> tlist = new List<T>{el,el,el};  // line 119

                mapc(tlist, (T el2) => 


                    List<T> ttlist = new List<T>(el2,el2,el2);   // line







Results in 

Utils.cs(122,26): error CS0246: The type or namespace name `T' could not
be foun

d. Are you missing a using directive or an assembly reference?


So, in line 122 T is unknown, in line 119, it goes fine. So the problem
only seems to occur at a sufficient level of nesting of generic lambdas.


Kind regards,





-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080430/624fd781/attachment-0001.html 

More information about the Mono-list mailing list