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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 18 10:48:18 PDT 2013


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 at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at 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: -------


More information about the Digitalmars-d-bugs mailing list