[Issue 9947] reduce of an array of structs with an immutable field
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 25 12:27:58 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=9947
monarchdodra at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |monarchdodra at gmail.com
--- Comment #2 from monarchdodra at gmail.com 2014-02-25 12:27:55 PST ---
(In reply to comment #0)
> 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
I think it is acceptable to require that whatever the type being reduced be
assignable? It would be more friendly if it asserts though.
--
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