[Issue 12434] New: std.algorithm.sum of immutable array too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 21 12:00:37 PDT 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12434
Summary: std.algorithm.sum of immutable array too
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2014-03-21 12:00:30 PDT ---
void main() {
import std.algorithm: sum, map;
auto a1 = [10, 20];
auto t1 = sum(a1); // OK
immutable a2 = [10, 20];
auto t2 = sum(a2); // Error
auto t3 = a2.map!(x => x).sum; // Error
}
dmd 2.066alpha:
...\dmd2\src\phobos\std\algorithm.d(1087,15): Error: template std.algorithm.sum
cannot deduce function from argument types !()(immutable(int)[],
immutable(int)), candidates are:
...\dmd2\src\phobos\std\algorithm.d(1079,6): std.algorithm.sum(R)(R r)
if (isInputRange!R && !isInfinite!R && is(typeof(r.front + r.front)))
...\dmd2\src\phobos\std\algorithm.d(1090,6): std.algorithm.sum(R, E)(R
r, E seed) if (isInputRange!R && !isInfinite!R && is(typeof(seed = seed +
r.front)))
test.d(6,18): Error: template instance std.algorithm.sum!(immutable(int)[])
error instantiating
...\dmd2\src\phobos\std\algorithm.d(1087,15): Error: template std.algorithm.sum
cannot deduce function from argument types !()(MapResult!(__lambda1,
immutable(int)[]), immutable(int)), candidates are:
...\dmd2\src\phobos\std\algorithm.d(1079,6): std.algorithm.sum(R)(R r)
if (isInputRange!R && !isInfinite!R && is(typeof(r.front + r.front)))
...\dmd2\src\phobos\std\algorithm.d(1090,6): std.algorithm.sum(R, E)(R
r, E seed) if (isInputRange!R && !isInfinite!R && is(typeof(seed = seed +
r.front)))
test.d(7,30): Error: template instance std.algorithm.sum!(MapResult!(__lambda1,
immutable(int)[])) error instantiating
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list