Fix reduce regression 13304.

Also cover test case 10709.
This commit is contained in:
monarchdodra 2014-08-17 19:45:17 +02:00
parent 06356c4571
commit 76f994abf9

View file

@ -865,10 +865,11 @@ private template ReduceSeedType(E)
{ {
E e = E.init; E e = E.init;
static alias ReduceSeedType = Unqual!(typeof(fun(e, e))); static alias ReduceSeedType = Unqual!(typeof(fun(e, e)));
static assert(is(typeof({
ReduceSeedType s = e; //Check the Seed type is useable.
s = fun(s, e); ReduceSeedType s = ReduceSeedType.init;
})), algoFormat("Unable to deduce an acceptable seed type for %s with element type %s.", fullyQualifiedName!fun, E.stringof)); static assert(is(typeof({ReduceSeedType s = e;})) && is(typeof(s = fun(s, e))),
algoFormat("Unable to deduce an acceptable seed type for %s with element type %s.", fullyQualifiedName!fun, E.stringof));
} }
} }
@ -1109,6 +1110,12 @@ unittest //12569
static assert(!is(typeof(reduce!(all, all)(tuple(1, 1), "hello")))); static assert(!is(typeof(reduce!(all, all)(tuple(1, 1), "hello"))));
} }
unittest //13304
{
int[] data;
static assert(is(typeof(reduce!((a, b)=>a+b)(data))));
}
// sum // sum
/** /**
Sums elements of $(D r), which must be a finite input range. Although Sums elements of $(D r), which must be a finite input range. Although