``` struct G { ubyte[] I; alias I this; // Comment out to fix } auto M(ubyte[]) { G N; return N; } struct Tuple(fields...) { fields expand; } alias P = Tuple!(); struct R { int T; } struct U { R V; } void X() { import std.array; Appender!(U[])[P] Z; auto HB = P(); Z[HB].put(cast(U[])[].M); } ``` Introduced by https://github.com/dlang/dmd/pull/9516
The extra R struct is not necessary in the above The following crashes with a much deeper call stack (27 vs. 8): struct G { ubyte[] I; alias I this; } auto M(ubyte[]) { G N; return N; } struct U { int V; } void X() { func((cast(U[])[].M)); } void func(U[]) {}
The expression that is causing the problem is `cast(U[])M([]).I` Unfortunately `I` is being reported as type `G` instead of type `ubyte[]` and that is why the compiler errors. So I don't think PR 9516 has introduced any bug, but I do believe it has revealed a problem elsewhere in the compiler. The solution will be to ensure `I` has a type of `ubyte[]` instead of G.
Actually, scratch what I wrote above. That was the result after I added some debugging code that incorrectly reported the type. The problem appears to be that the `alias this` is not being resolved by the time the cast takes place.
dlang/dmd pull request #9735 "Fix Issue 19840 - Ice in e2ir.d visit(CastExp)" was merged into stable: - d07e3b88611a1f394bec7fd720cc6d8cac0d9daf by JinShil: Fix Issue 19840 - Ice in e2ir.d visit(CastExp) https://github.com/dlang/dmd/pull/9735