[Issue 1654] Array concatenation result should be implicitly castable between mutable and immutable if the elements support it.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 26 13:56:05 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=1654
Simen Kjaeraas <simen.kjaras at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |simen.kjaras at gmail.com
Resolution|WORKSFORME |---
--- Comment #33 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
It works for string literals, but not for two variables:
unittest {
import std.meta : AliasSeq;
static foreach (T; AliasSeq!(char, const(char), immutable(char))) {{
pragma(msg, T.stringof, ":");
T[] s = "".dup;
// Result type of concatenation may differ:
pragma(msg, "Variable: ", typeof(s~s).stringof);
pragma(msg, "Literal: ", typeof(s~"").stringof);
// Two const(char)[]s:
{
char* p1 = (s~s).ptr;
immutable(char)* p2 = (s~s).ptr;
const(char)* p3 = (s~s).ptr;
char[] a = s~s;
string b = s~s;
const(char)[] c = s~s;
}
// One literal:
{
char* p1 = (s~"").ptr;
immutable(char)* p2 = (s~"").ptr;
const(char)* p3 = (s~"").ptr;
char[] a = s~"";
string b = s~"";
const(char)[] c = s~"";
}
}}
}
So no, this is not fixed. When it's fixed, all of the above should compile
without issue.
--
More information about the Digitalmars-d-bugs
mailing list