https://issues.dlang.org/show_bug.cgi?id=7514
--- Comment #12 from Kenji Hara <[email protected]> --- (In reply to bearophile_hugs from comment #11) > (In reply to Kenji Hara from comment #10) > > > I think the cast from int[] to int[2][1] should not be accepted. > > Can you please explain why? > > Currently this is accepted: > int[2] m = cast(int[2])[1, 2]; In cast(int[2])[1, 2], the array literal can *structurally* match to the type int[2] - all elements can be implicitly convertible to int, and the array literal contains 2 elements. Therefore the cast is accepted. Contrary to that, in cast(int[2][1])[1, 2] compiler cannot find any structural conversions. Therefore it will be a reinterpret cast, but dmd has no proper codegen way for the cast from int[] to int[2][1]. That's why the former is accepted but the latter isn't. --
