← Back to index
|
Original Bugzilla link
Bug 10408 – Two-function std.algorithm.reduce of a const array
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-06-18T10:48:00Z
Last change time
2013-06-22T11:19:36Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0
by bearophile_hugs — 2013-06-18T10:48:17Z
import std.algorithm: min, max, reduce; void main() { const numbers = [10, 30, 20]; immutable m = numbers.reduce!(min); // OK immutable mm = numbers.reduce!(min, max); // error } DMD 2.063.2 gives: ...\dmd2\src\phobos\std\conv.d(3610): Error: cannot modify const expression *chunk ...\dmd2\src\phobos\std\algorithm.d(736): Error: template instance std.conv.emplace!(const(int), const(int)) error instantiating test.d(5): instantiated from here: reduce!(const(int)[]) ...\dmd2\src\phobos\std\algorithm.d(712): Error: can only initialize const member _expand_field_0 inside constructor ...\dmd2\src\phobos\std\algorithm.d(712): Error: can only initialize const member _expand_field_1 inside constructor ...\dmd2\src\phobos\std\algorithm.d(739): Error: template instance std.algorithm.reduce!(min, max).reduce!(Tuple!(const(int), const(int)), const(int)[]) error instantiating test.d(5): instantiated from here: reduce!(const(int)[]) test.d(5): Error: template instance std.algorithm.reduce!(min, max).reduce!(const(int)[]) error instantiating
Comment #1
by irritate — 2013-06-21T19:57:23Z
https://github.com/D-Programming-Language/phobos/pull/1361
Comment #2
by github-bugzilla — 2013-06-22T10:28:34Z
Commits pushed to master at
https://github.com/D-Programming-Language/phobos
https://github.com/D-Programming-Language/phobos/commit/58d403a02d1fe445384ac34a965b76b3d975032e
Issue 10408 - Fix compile error with multiple-function reduce on a const range.
https://github.com/D-Programming-Language/phobos/commit/3f902900387a9e094e8e325c8e4a1048f577eefe
Merge pull request #1361 from irritate/issue_10408 Issue 10408 - Fix compile error with multiple-function reduce on a const...