www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16018] New: fold size_t[] with int seed causes forward

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

          Issue ID: 16018
           Summary: fold size_t[] with int seed causes forward reference
                    error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

% cat test.d
import std.algorithm;
void foo(size_t[] shape)
{
    shape[].fold!"a*b"(1);
}
% dmd test.d
std/traits.d(551): Error: forward reference of variable parentPrefix
std/traits.d(461): Error: template instance std.traits.fqnSym!(binaryFun) error
instantiating
std/algorithm/iteration.d(2680):        instantiated from here:
fullyQualifiedName!(binaryFun)
std/algorithm/iteration.d(2661):        instantiated from here:
reduceImpl!(false, ulong[], int)
std/algorithm/iteration.d(2645):        instantiated from here:
reducePreImpl!(ulong[], int)
std/algorithm/iteration.d(3024):        instantiated from here: reduce!(int,
ulong[])
test.d(4):        instantiated from here: fold!(ulong[], int)
std/algorithm/iteration.d(2677): Error: static assert  __error
std/algorithm/iteration.d(2661):        instantiated from here:
reduceImpl!(false, ulong[], int)
std/algorithm/iteration.d(2645):        instantiated from here:
reducePreImpl!(ulong[], int)
std/algorithm/iteration.d(3024):        instantiated from here: reduce!(int,
ulong[])
test.d(4):        instantiated from here: fold!(ulong[], int)

works fine if you replace 1 with size_t(1)

--
May 11 2016