D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 9823 - Delegate accepting element not accepted in std.range.put
Summary: Delegate accepting element not accepted in std.range.put
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2013-03-27 22:26 UTC by Jesse Phillips
Modified: 2013-11-22 18:23 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jesse Phillips 2013-03-27 22:26:28 UTC
When providing a delegate to the std.range.put() function, compilation fails.

import std.range;

void main() {
    string[] nameList1 = ["Anders", "David", "James", "Jeff", "Joe"];

    void mySink(in char[] a) { }
    auto r = &mySink;
    static assert(isOutputRange!(typeof(r), string)); // Passes
    put(r, nameList1); // Fails
}

std/range.d(611): Error: static assert  "Cannot put a string[] into a void delegate(const(char[]) a)"

------

This appears to be an issue of line 597

    else static if ((usingPut || usingFront) && isInputRange!E && is(typeof(put(r, e.front))))
    {
        for (; !e.empty; e.popFront()) put(r, e.front);
    }

Where it should be checking (!usingPut && !usingFront) as they refer to
usingPut: Use put method from struct or class.
usingFront: Output range is an InputRange and may accept assignment to front.
Comment 1 yebblies 2013-07-27 22:33:23 UTC
*** Issue 10571 has been marked as a duplicate of this issue. ***
Comment 2 yebblies 2013-07-27 22:44:53 UTC
Turned into a pull request:

https://github.com/D-Programming-Language/phobos/pull/1437