[Issue 14553] New: The return types of std.array.array for narrow strings conflicts with its documentation

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu May 7 04:24:33 PDT 2015


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

          Issue ID: 14553
           Summary: The return types of std.array.array for narrow strings
                    conflicts with its documentation
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: ttanjo at gmail.com

The document of std.array.array for narrow string says "This (snip) always
returns a dchar[], const(dchar)[], or immutable(dchar)[] depends on the
constness of the input."

However, array for them always returns dchar[] instead of qualified array.

The following example reproduces the problem.
I checked it by using dmd trunk in Linux x64.

---
import std.stdio;
import std.array;
import std.traits;
import std.typetuple;

void main() {
    foreach(T; TypeTuple!(char, wchar))
    {
        writeln(ReturnType!(array!(T[])).stringof);
        writeln(ReturnType!(array!(const(T)[])).stringof);
        writeln(ReturnType!(array!(immutable(T)[])).stringof);
    }
}
---

Expected output:
dchar[]
const(dchar)[]
immutable(dchar)[]
dchar[]
const(dchar)[]
immutable(dchar)[]

Actual output:
dchar[]
dchar[]
dchar[]
dchar[]
dchar[]
dchar[]

--


More information about the Digitalmars-d-bugs mailing list