February 25, 2014 [Issue 9123] New: std.algorithm.reduce is not pure nothrow on const array | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: bearophile_hugs@eml.cc CC: monarchdodra@gmail.com monarchdodra@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |monarchdodra@gmail.com Resolution| |WORKSFORME --- Comment #0 from bearophile_hugs@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@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: ------- |
Copyright © 1999-2021 by the D Language Foundation