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;
static alias ReduceSeedType = Unqual!(typeof(fun(e, e)));
static assert(is(typeof({
ReduceSeedType s = e;
s = fun(s, e);
})), algoFormat("Unable to deduce an acceptable seed type for %s with element type %s.", fullyQualifiedName!fun, E.stringof));
//Check the Seed type is useable.
ReduceSeedType s = ReduceSeedType.init;
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"))));
}
unittest //13304
{
int[] data;
static assert(is(typeof(reduce!((a, b)=>a+b)(data))));
}
// sum
/**
Sums elements of $(D r), which must be a finite input range. Although