Bug 12172 – Refused sum(transversal)

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-02-15T02:01:00Z
Last change time
2014-02-23T13:01:05Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-02-15T02:01:19Z
import std.algorithm: reduce, sum; import std.range: transversal; alias mySum = reduce!q{a + b}; void main() { const data = [[1, 2], [10, 20]]; mySum(0, data.transversal(0)); // OK sum(0, data.transversal(0)); // Error } dmd 2.065beta3 gives: test.d(7,8): Error: template std.algorithm.sum cannot deduce function from argument types !()(int, Transversal!(const(int[])[], cast(TransverseOptions)0)), candidates are: ...\dmd2\src\phobos\std\algorithm.d(1070,6): std.algorithm.sum(R)(R r) if (isInputRange!R && !isFloatingPoint!(ElementType!R) && !isInfinite!R) ...\dmd2\src\phobos\std\algorithm.d(1115,6): std.algorithm.sum(R)(R r) if (hasSlicing!R && hasLength!R && isFloatingPoint!(ElementType!R)) ...\dmd2\src\phobos\std\algorithm.d(1145,6): std.algorithm.sum(R)(R r) if (isInputRange!R && !(hasSlicing!R && hasLength!R) && isFloatingPoint!(ElementType!R) && !isInfinite!R)
Comment #1 by peter.alexander.au — 2014-02-22T11:09:21Z
Sum doesn't allow for a seed like reduce. Is this meant to be an enhancement request, or just a mistake? FWIW: sum(data.transversal(0)) works fine.
Comment #2 by bearophile_hugs — 2014-02-23T13:01:05Z
(In reply to comment #1) > Sum doesn't allow for a seed like reduce. Is this meant to be an enhancement > request, or just a mistake? Probably it's just a mistake, sorry. Closed.