[Issue 13829] New: std.uni.byCodePoint for strings has length

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Dec 7 05:42:03 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13829

          Issue ID: 13829
           Summary: std.uni.byCodePoint for strings has length
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: schuetzm at gmx.net

import std.uni;
    static assert(__traits(compiles, "é".byCodePoint.length));
    pragma(msg, typeof("é".byCodePoint)); // => string

The problem is that `byCodePoint(w?string.init)` returns its argument
(string/wstring) which of course defines `length`, instead of a wrapper that
doesn't.

The reason is once again auto-decoding. In std/uni.d(6644):

    Range byCodePoint(Range)(Range range)
        if(isInputRange!Range && is(Unqual!(ElementType!Range) == dchar))
    {
        return range;
    }

`Unqual!(ElementType!string)` is of course `dchar`.

Brought up in this discussion:
http://forum.dlang.org/thread/ovzcetxbrdblpmyizdjr@forum.dlang.org#post-ovzcetxbrdblpmyizdjr:40forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list