On Tue, 22 Apr 2014 14:17:57 -0400, Ali Çehreli <acehr...@yahoo.com> wrote:

I don't think there is slicing an rvalue though. (?) reduce() is taking a copy of the seed and then returning a slice to it because the user slices it in their lambda. It effectively does the following, which unfortunately compiles:

int[] foo()
{
     int[1] sum;
     return sum[];    // <-- no warning
}

It's not slicing an rvalue, but the above is trivially no different than:

int[] foo()
{
   int[1] sum;
   return sum;
}

which does NOT compile.

The issue is that D's escape analysis is very very simplistic. It would be nice if it were better.

Ironically, because of return type inference in lambdas, you circumvented the check!

-Steve

Reply via email to