[Issue 9123] New: std.algorithm.reduce is not pure nothrow on const array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 25 12:24:53 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=9123

           Summary: std.algorithm.reduce is not pure nothrow on const
                    array
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: RESOLVED
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc
                CC: monarchdodra at gmail.com



monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra at gmail.com
         Resolution|                            |WORKSFORME


--- Comment #0 from bearophile_hugs at eml.cc 2012-12-07 16:24:22 PST ---
In this program spam1 and spam2 differ because 'items' is const in spam2:


import std.algorithm: reduce;
struct Foo {}
immutable Foo zero;
static Foo bar(Foo, Foo) pure nothrow {
    return zero;
}
void spam1(Foo[] items) pure nothrow {
    reduce!bar(zero, items);
}
void spam2(const Foo[] items) pure nothrow {
    reduce!bar(zero, items);
}
void main() {}


Expected: both spam1 and spam2 allowed to be pure nothrow.

But DMD 2.061alpha gives:

test.d(11): Error: pure function 'spam2' cannot call impure function 'reduce'
test.d(11): Error: reduce is not nothrow
test.d(10): Error: function test.spam2 'spam2' is nothrow yet may throw

--- Comment #1 from monarchdodra at gmail.com 2014-02-25 12:24:50 PST ---
Don't know when fixed, but the snippet works fine now in head.

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