Wrong lowering for a[b][c]++

Timon Gehr timon.gehr at gmx.ch
Fri Mar 23 02:33:50 PDT 2012


On 03/23/2012 07:15 AM, Andrej Mitrovic wrote:
> On 3/23/12, H. S. Teoh<hsteoh at quickfur.ath.cx>  wrote:
>> WAT?! What on earth is "cast()" supposed to mean??
>
> I've no idea. It's probably a front-end bug and the cast forces the
> compiler to.. come to its senses?

That part is not a bug, it is specified.

http://dlang.org/expression.html#CastExpression

"Casting with no Type or CastQual removes any top level const, 
immutable, shared or inout type modifiers from the type of the 
UnaryExpression."

What is a bug is that array initializers cannot be used to initialize 
structs through associative array alias this.

Maybe you are also missing that this is valid code:

int[] a = [1 : 2, 3 : 4];

This only works for initializers of the form [ ... ]. The cast() removes 
that possibility.

This is why the compiler gets confused.



More information about the Digitalmars-d mailing list