www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14909] New: Template argument of

https://issues.dlang.org/show_bug.cgi?id=14909

          Issue ID: 14909
           Summary: Template argument of std.algoirthm.iteration.chunkBy
                    cannot access a local variable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

The following code cannot be compiled.
I checked it by using DMD trunk (v2.068-devel-407dac3) in Mac OSX.

---
import std.algorithm.iteration;

void main()
{
    auto n = 3;
    auto s = [1,2,3].chunkBy!(a => a+n); ///  Error: function
sample.main.ChunkByImpl!(__lambda1, int[]).ChunkByImpl.__lambda12 cannot access
frame of function D main
}
---

--
Aug 12 2015