[Issue 10262] New: utf.decodeFront doesn't work with a string slice

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 4 00:34:59 PDT 2013


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

           Summary: utf.decodeFront doesn't work with a string slice
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: gdkslpmq at spam4.me


--- Comment #0 from Derek Rhodes <gdkslpmq at spam4.me> 2013-06-04 00:34:58 PDT ---
The code

import std.utf;

void main() {
    string str = "asdf";
    size_t size;

    decodeFront(str[1..$], size);
}

fails to compile, with the error

test.d(8): Error: template std.utf.decodeFront does not match any function
template declaration. Candidates are:
/usr/include/d/std/utf.d(978):        std.utf.decodeFront(S)(ref S str, out
size_t numCodeUnits) if (!isSomeString!(S) && isInputRange!(S) &&
isSomeChar!(ElementType!(S)))
/usr/include/d/std/utf.d(1012):        std.utf.decodeFront(S)(ref S str, out
size_t numCodeUnits) if (isSomeString!(S))
/usr/include/d/std/utf.d(1038):        std.utf.decodeFront(S)(ref S str) if
(isInputRange!(S) && isSomeChar!(ElementType!(S)))
/usr/include/d/std/utf.d(978): Error: template std.utf.decodeFront cannot
deduce template function from argument types !()(string, ulong)

Casting str[1..$] to a string explicitly results in the same error. Putting the
slice outside the function call, like

string s2 = str[1..$];
decodeFront(s2, size);

Fixed the error.

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