mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 19:49:36 +03:00
Fix reduce regression 13304.
Also cover test case 10709.
This commit is contained in:
parent
06356c4571
commit
76f994abf9
1 changed files with 11 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue