mirror of
https://github.com/dlang/phobos.git
synced 2025-05-12 23:29:01 +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;
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue