[Issue 9823] New: Delegate accepting element not accepted in std.range.put

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 27 22:26:29 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9823

           Summary: Delegate accepting element not accepted in
                    std.range.put
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: Jesse.K.Phillips+D at gmail.com


--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D at gmail.com> 2013-03-27 22:26:28 PDT ---
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.

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