"Steven Schveighoffer" <schvei...@yahoo.com> wrote in message news:op.v13w8td2eav7ka@localhost.localdomain... > On Tue, 20 Sep 2011 07:33:20 -0400, bearophile <bearophileh...@lycos.com> > wrote: > >> void foo(const ref int[5] a) {} >> void main() { >> immutable int[5] arr; >> foo(arr); // Error? >> } > > The complaint from the compiler is that cast(const(int[5u])) arr is not an > lvalue.
It's a bug, the compiler shouldn't be inserting a cast when the value implicitly converts. It's also a bug when the compiler tries to optimise away the variable to a literal when passing by reference, I've got a patch for this I haven't written up yet.