Thread overview
[Issue 19840] Ice in e2ir.d visit(CastExp) assert(false, "This case should have been rewritten to `__ArrayCast` in the semantic phase");
May 01, 2019
Nicholas Wilson
May 01, 2019
Nicholas Wilson
May 02, 2019
Mike Franklin
May 02, 2019
Mike Franklin
May 02, 2019
Dlang Bot
May 01, 2019
https://issues.dlang.org/show_bug.cgi?id=19840

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice

--
May 01, 2019
https://issues.dlang.org/show_bug.cgi?id=19840

--- Comment #1 from Nicholas Wilson <iamthewilsonator@hotmail.com> ---
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[]) {}

--
May 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19840

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #2 from Mike Franklin <slavo5150@yahoo.com> ---
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.

--
May 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19840

--- Comment #3 from Mike Franklin <slavo5150@yahoo.com> ---
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.

--
May 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19840

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--