[Issue 9947] New: reduce of an array of structs with an immutable field

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 16 16:16:16 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9947

           Summary: reduce of an array of structs with an immutable field
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          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 2013-04-16 16:16:16 PDT ---
Maybe this should work:


import std.algorithm: reduce;
struct Foo {
    immutable int x;
}
void main() {
    auto data = [Foo(0)];
    reduce!((a, b) => a)(data);
}



DMD 2.063alpha gives:

...\dmd2\src\phobos\std\algorithm.d(702): Error: cannot modify struct result
Foo with immutable members
...\dmd2\src\phobos\std\algorithm.d(723): Error: template instance
test.main.reduce!(__lambda3).reduce!(Foo,Foo[]) error instantiating
test.d(7):        instantiated from here: reduce!(Foo[])
test.d(7): Error: template instance test.main.reduce!(__lambda3).reduce!(Foo[])
error instantiating

-- 
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