Compiler errors and recursive nested functions

Ali Çehreli acehreli at yahoo.com
Wed Jun 12 15:48:32 PDT 2013


On 06/12/2013 03:45 PM, Dylan Knutson wrote:
> Hello! I'm trying to make a deepMap function which operates on the
> deepest non-range element of an array. I think that this function should
> theoretically work, however there are some compiler errors that I can't
> quite understand.
>
> Here's the code: http://dpaste.dzfl.pl/97918311
>
> And the compiler error because DPaste's compiler service seems to be
> offline:
>
> src\algorithm_util.d(26): Error: function
> algorithm_util.__unittestL34_5.deepMap!(__lambda4, int[]).deepMap is a
> nested function and cannot be accessed from
> algorithm_util.__unittestL34_5.deepMap!(__lambda4,
> int[][]).deepMap.__lambda2300!(int[]).__lambda2300DMD
> v2.064 DEBUG
>
> deepMap works just fine if I pass in an array that isn't nested, so this
> will work:
>
>      auto a = [1, 2, 3];
>      auto b = a.deepMap!(a => a + 1)();
>      writeln(b);
>      // "[2, 3, 4]"
>
> Can someone explain what is going on?
>
> Thank you,
> Dylan Knutson

Perhaps this limitation:

   http://d.puremagic.com/issues/show_bug.cgi?id=5710

Ali



More information about the Digitalmars-d-learn mailing list