www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10408] New: Two-function std.algorithm.reduce of a const array

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10408

           Summary: Two-function std.algorithm.reduce of a const array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-06-18 10:48:17 PDT ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 18 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10408


irritate <irritate gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irritate gmail.com


--- Comment #1 from irritate <irritate gmail.com> 2013-06-21 19:57:23 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1361

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10408



--- Comment #2 from github-bugzilla puremagic.com 2013-06-22 10:28:34 PDT ---
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...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10408


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 22 2013