www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13829] New: std.uni.byCodePoint for strings has length


          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 puremagic.com
          Reporter: schuetzm 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

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

Dec 07 2014