I may have found a bug in assumeUTF(), but being new to D, I'm not sure.

The description:

Assume the given array of integers arr is a well-formed UTF string and return it typed as a UTF string. ubyte becomes char, ushort becomes wchar and uint becomes dchar. Type qualifiers are preserved.

The declaration:

```d
auto assumeUTF(T)(T[] arr)
if (staticIndexOf!(immutable T, immutable ubyte, immutable ushort, immutable uint) != -1)
```

Shouldn't that precondition's `immutable T` be simply `T`?

As it stands, I can do this with no complaints from the compiler...

```d
string test(ubyte[] arr)
{
    import std.string;
    return arr.assumeUTF;
}

```

...and accidentally end up with a "string" pointing at mutable data.

Am I missing something?

Reply via email to