[Issue 7924] New: reduce does not work with immutable/const as map and filter do
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 16 08:22:56 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7924
Summary: reduce does not work with immutable/const as map and
filter do
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: major
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: russel at winder.org.uk
--- Comment #0 from Russel Winder <russel at winder.org.uk> 2012-04-16 08:23:47 PDT ---
(I have marked this as x86_64/Linux as that is the only platform I have tried
this on. I am fairly convinced it is an all/all though.)
The following code:
import std.algorithm ;
import std.range ;
import std.stdio ;
void main ( immutable string[] args ) {
immutable r = iota ( 0 , 10 ) ;
writeln ( map ! ( i => i * i ) ( r ) ) ;
writeln ( filter ! ( i => true ) ( r ) ) ;
writeln ( reduce ! ( ( a , b ) => a + b ) ( 10 , r ) ) ;
}
fails to compile using DMD 2.059 with the message:
/home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/algorithm.d(725):
Error: function std.range.iota!(int,int).iota.Result.popFront () is not
callable using argument types ()
/home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/algorithm.d(725):
Error: function std.range.iota!(int,int).iota.Result.front () is not callable
using argument types ()
issue_XXXX.d(9): Error: template instance
issue_XXXX.main.reduce!(__lambda7).reduce!(int,immutable(Result)) error
instantiating
Failed: 'dmd' '-v' '-o-' 'issue_XXXX.d' '-I.'
If the immutable is replaced with const the same message ensues with
s/immutable/const/. If the reduce is commented out then it all works:
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
reduce is thus not consistent with map and filter, which I think has to be
considered a serious error.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list