On 07/08/2012 11:47 PM, Lemonfiend wrote:
Hi,

I seem to have run into a strange error..
When I put tmp1 outside the main loop, it compiles fine and gives the
expected output.
When tmp1 is put inside the main loop, the compiler seems to get stuck
in a loop?

I've tested it on: http://dlang.org/index.html

See error on bottom (lol)

--------------------
#!/usr/bin/rdmd

import std.stdio;

//immutable int[] tmp1 = [1, 2]; // compiles

void main()
{
    immutable int[] tmp1 = [1, 2]; // does not compile

    int[tmp1.length] tmp2 = tmp1;

    tmp2[] += 1;

    writeln(tmp1);
    writeln(tmp2);
}

--------------------


I'd argue that this is a bug. The length of an immutable variable with
a constant initializer should be a constant expression.

Presumably this is caused by the compiler rewriting the array literal
into an allocation.

Reply via email to