This happens with dmd 2.058 and probably earlier ones too. Compile the following with dmd -inline. Note how the assertions fail when the constness of the arguments to the array append doesn't match: char[] toStr(char[] s) { return s; } const(char)[] toStr(const(char)[] s) { return s; } void main() { { auto str = "abcd"; const(char)[] res; res ~= toStr(str); assert(res == str); // Fine } { auto str = "abcd".dup; char[] res; res ~= toStr(str); assert(res == str); // Fine } { auto str = "abcd"; char[] res; res ~= toStr(str); assert(res == str); // Fail } { auto str = "abcd".dup; const(char)[] res; res ~= toStr(str); assert(res == str); // Fail } }
I meant 2.059 (although 2.058 probably has it too).
Works now.