Bug 19840 – Ice in e2ir.d visit(CastExp) assert(false, "This case should have been rewritten to `__ArrayCast` in the semantic phase");

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-05-01T13:16:34Z
Last change time
2019-05-02T07:26:24Z
Keywords
ice
Assigned to
No Owner
Creator
Nicholas Wilson

Comments

Comment #0 by iamthewilsonator — 2019-05-01T13:16:34Z
``` 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
Comment #1 by iamthewilsonator — 2019-05-01T13:36:15Z
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[]) {}
Comment #2 by slavo5150 — 2019-05-02T00:12:22Z
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.
Comment #3 by slavo5150 — 2019-05-02T00:59:04Z
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.
Comment #4 by dlang-bot — 2019-05-02T07:26:24Z
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