www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5663] New: std.array.Appender.put bug

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5663

           Summary: std.array.Appender.put bug
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



Following test fails.
Appender.put treats const(T)[]/immutable(T)[] argument as general input range.

unittest
{
    alias .std.array.Appender!(char[]) StdApp;
    {   StdApp app;
        app.put("\xE3");                    //thrown "Invalid UTF-8 sequence"
        assert(app.data == "\xE3");
    }

    {   StdApp app;
        app.put(cast(const(char)[])"\xE3"); //thrown "Invalid UTF-8 sequence"
        assert(app.data == "\xE3");
    }
    {   StdApp app;
        app.put(cast(char[])"\xE3");        //char[] -> ok
        assert(app.data == "\xE3");
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5663




Following patch will fix this bug.

 std/array.d |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/std/array.d b/std/array.d
index c0f466c..e0c64f0 100644
--- a/std/array.d
+++ b/std/array.d
   -1196,7 +1196,9    Appends an entire range to the managed array.
         // note, we disable this branch for appending one type of char to
         // another because we can't trust the length portion.
         static if (!(isSomeChar!T && isSomeChar!(ElementType!Range) &&
-                     !is(Range == Unqual!(T)[])) &&
+                     !is(Range == Unqual!T[]) &&
+                     !is(Range == const(T)[]) &&
+                     !is(Range == immutable(T)[])) &&
                    is(typeof(items.length) == size_t))
         {
             // optimization -- if this type is something other than a string,

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 27 2011