import std.stdio; struct S {string s; this(string x){s=x;}} immutable(S) mkS(){ return S("mks hi"); } void main(char[][] args) { immutable(S) s = mkS(); immutable(S)[] ss; ss ~= S("plain hi"); ss ~= cast(immutable(S)) S("plain hi"); //ss ~= mkS(); // --> "Internal error: ../ztc/cod1.c 1684" writeln(s.s, ", ", ss[0].s); } I think (hope?) this is all valid code. I.e., ss ~= S("Hi"); //should be ok ss.length = ss.length + 1; ss[$-1] = S("plain hi"); //should fail to compile (as it indeed does) In any case there is an ICE. Error: ss[0] isn't mutable Error: ss[0] isn't mutable //ss[0] = S("fail"); --> Error: ss[0] isn't mutable
Good news: This is already fixed in DMD 2.032, which will hopefully be released tomorrow.
Fixed dmd 2.032