www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13935] New: Problem with std.algorithm.cartesianProduct(map,

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

          Issue ID: 13935
           Summary: Problem with std.algorithm.cartesianProduct(map, map)
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

void main() {
    import std.algorithm: map, cartesianProduct;
    auto seq = [1, 2].map!(x => x);
    foreach (pair; cartesianProduct(seq, seq)) {}
}


dmd 2.067alpha gives:

...\dmd2\src\phobos\std\algorithm.d(14489,20): Error: function
std.algorithm.cartesianProduct!(MapResult!(__lambda1, Result),
MapResult!(__lambda1, Result)).cartesianProduct.Result.save cannot get frame
pointer to main
...\dmd2\src\phobos\std\algorithm.d(14489,20): Error: function
std.algorithm.cartesianProduct!(MapResult!(__lambda1, Result),
MapResult!(__lambda1, Result)).cartesianProduct.Result.save cannot get frame
pointer to main
...\dmd2\src\phobos\std\algorithm.d(14489,20): Error: function
std.algorithm.cartesianProduct!(MapResult!(__lambda1, Result),
MapResult!(__lambda1, Result)).cartesianProduct.Result.save cannot get frame
pointer to main
...\dmd2\src\phobos\std\algorithm.d(14489,20): Error: function
std.algorithm.cartesianProduct!(MapResult!(__lambda1, Result),
MapResult!(__lambda1, Result)).cartesianProduct.Result.save cannot get frame
pointer to main


Taking a look at the std.algorithm.cartesianProduct implementation:


auto cartesianProduct(RR...)(RR ranges)
    if (ranges.length >= 2 &&
        allSatisfy!(isForwardRange, RR) &&
        !anySatisfy!(isInfinite, RR))
{
...
    static struct Result
    {
...
         property Result save()
        {
            Result copy; // Error message here *******
            foreach (i, r; ranges)
            {
                copy.ranges[i] = r.save;
                copy.current[i] = current[i].save;
            }
            copy.empty = this.empty;
            return copy;
        }
    }
...

-----------------------

--
Jan 04 2015