www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Compilation failure

reply "Lemonfiend" <no email.here> writes:
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);
}

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

Compilation failure:
834.d(9): Error: Integer constant expression expected instead of 
(tmp1 = [1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length/usr/local/include/dmd2/std/format.d(419): Error: 
template instance std.format.getNthInt!(int[(tmp1 = 
[1,2]).length]) error 
instantiating/usr/local/include/dmd2/std/stdio.d(687): 
instantiated from here: 
formattedWrite!(LockingTextWriter,char,int[(tmp1 = 
[1,2]).length])/usr/local/include/dmd2/std/stdio.d(1574): 
instantiated from here: write!(int[(tmp1 = 
[1,2]).length],char)834.d(16): instantiated from here: 
writeln!(int[(tmp1 = [1,2]).length])834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length834.d(9): Error: Integer constant expression 
expected instead of (tmp1 = [1,2]).length834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length/usr/local/include/dmd2/std/format.d(2593): Error: 
template std.format.formatValue does not match any function 
template declaration/usr/local/include/dmd2/std/format.d(2593): 
Error: template std.format.formatValue cannot deduce template 
function from argument types !()(LockingTextWriter,int[(tmp1 = 
[1,2]).length],FormatSpec!(char))/usr/local/include/dmd2/std/format.d(471): 
Error: template instance 
std.format.formatNth!(LockingTextWriter,char,int[(tmp1 = 
[1,2]).length]) error 
instantiating/usr/local/include/dmd2/std/stdio.d(687): 
instantiated from here: 
formattedWrite!(LockingTextWriter,char,int[(tmp1 = 
[1,2]).length])/usr/local/include/dmd2/std/stdio.d(1574): 
instantiated from here: write!(int[(tmp1 = 
[1,2]).length],char)834.d(16): instantiated from here: 
writeln!(int[(tmp1 = [1,2]).length])834.d(9): Error: Integer 
constant expression expected instead of (tmp1 = 
[1,2]).length/usr/local/include/dmd2/std/stdio.d(687): Error: 
template instance 
std.format.formattedWrite!(LockingTextWriter,char,int[(tmp1 = 
[1,2]).length]) error 
instantiating/usr/local/include/dmd2/std/stdio.d(1574): 
instantiated from here: write!(int[(tmp1 = 
[1,2]).length],char)834.d(16): instantiated from here: 
writeln!(int[(tmp1 = 
[1,2]).length])/usr/local/include/dmd2/std/stdio.d(1574): Error: 
template instance std.stdio.File.write!(int[(tmp1 = 
[1,2]).length],char) error instantiating834.d(16): instantiated 
from here: writeln!(int[(tmp1 = [1,2]).length])834.d(16): Error: 
template instance std.stdio.writeln!(int[(tmp1 = [1,2]).length]) 
error instantiating
--------------------
Jul 08 2012
next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
 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?

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

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

Generally the int[tmp1.length] syntax tries to define a fixed-sized array, but currently in D there are no VariableLengthArrays of C99, there are only dynamic arrays and fixed-sized arrays, so the size must be known at compile-time. But when tmp1 is defined inside the main, it is a dynamic array, so its length isn't a compile-time known value. This explains why it doesn't compile if tmp1 is defined inside the main(). The large number of the same error message is small a compiler diagnostic bug, that should be reported in bugzilla. When tmp1 is defined globally, dmd is doing something different, in some way it sees global immutables almost as enums... I don't know if this is present in D specs. Bye, bearophile
Jul 08 2012
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 07/11/2012 04:25 AM, ixid wrote:
 in some way it sees global immutables almost as enums

This seems like a bad idea. Consistency of behaviour would seem to be a good principle to expect of a language.

You are right; this is a bug.
Jul 10 2012
parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 07/19/2012 12:42 AM, bearophile wrote:
 Timon Gehr:

 You are right; this is a bug.

This discussion is not about an obscure language detail, it's a common situation.

FWIW, I have never run across it before.
 So if you think this is a bug, then please Timon file it in
 Bugzilla.

Usually bugs are reported by the guy who finds them, but here you go: http://d.puremagic.com/issues/show_bug.cgi?id=8400
Jul 18 2012
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 07/20/2012 01:53 PM, bearophile wrote:
 Timon Gehr:

 Usually bugs are reported by the guy who finds them, but here you go:
 http://d.puremagic.com/issues/show_bug.cgi?id=8400

Thank you, already fixed, it seems. Even if the fix is the opposite of what I have thought (I was thinking about forbidding global immutables too to be used as compile-time constants, while this fix turns local immutables too into enums. I hope this change doesn't cause a large mess).

They are not enums. They are interpretable at compile time if their initializer is interpretable at compile time. This makes sense. This is a bug fix. Similar code already works.
Jul 20 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
 The large number of the same error message is small a compiler 
 diagnostic bug, that should be reported in bugzilla.

It was already reported by me, I have added your case: http://d.puremagic.com/issues/show_bug.cgi?id=8312 Bye, bearophile
Jul 08 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
 When tmp1 is defined globally, dmd is doing something 
 different, in some way it sees global immutables almost  as 
 enums... I don't know if this is present in D specs.

You see it well with this test program: immutable int[] A = [1]; template Foo(size_t n) {} void main() { alias Foo!(A.length) fooA; // OK enum int[] B = [1]; alias Foo!(B.length) fooB; // OK immutable int[] C = [1]; alias Foo!(C.length) fooC; // error } Bye, bearophile
Jul 08 2012
prev sibling next sibling parent "Lemonfiend" <no email.here> writes:
On Sunday, 8 July 2012 at 22:10:32 UTC, bearophile wrote:
 When tmp1 is defined globally, dmd is doing something 
 different, in some way it sees global immutables almost  as 
 enums... I don't know if this is present in D specs.

You see it well with this test program: immutable int[] A = [1]; template Foo(size_t n) {} void main() { alias Foo!(A.length) fooA; // OK enum int[] B = [1]; alias Foo!(B.length) fooB; // OK immutable int[] C = [1]; alias Foo!(C.length) fooC; // error } Bye, bearophile

Thanks for the reply and explanation. I would never have thought that the declaration scope (local vs global) would have such an effect.. Is this specified anywhere?
Jul 10 2012
prev sibling next sibling parent "Lemonfiend" <no email.here> writes:
On Sunday, 8 July 2012 at 22:10:32 UTC, bearophile wrote:
 When tmp1 is defined globally, dmd is doing something 
 different, in some way it sees global immutables almost  as 
 enums... I don't know if this is present in D specs.

You see it well with this test program: immutable int[] A = [1]; template Foo(size_t n) {} void main() { alias Foo!(A.length) fooA; // OK enum int[] B = [1]; alias Foo!(B.length) fooB; // OK immutable int[] C = [1]; alias Foo!(C.length) fooC; // error } Bye, bearophile

Thanks for the reply and explanation. I would never have thought that the declaration scope (local vs global) would have such an effect.. Is this specified anywhere?
Jul 10 2012
prev sibling next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
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.
Jul 10 2012
prev sibling next sibling parent "ixid" <nuaccount gmail.com> writes:
in some way it sees global immutables almost  as enums

This seems like a bad idea. Consistency of behaviour would seem to be a good principle to expect of a language.
Jul 10 2012
prev sibling next sibling parent "Lemonfiend" <no email.here> writes:
On Wednesday, 11 July 2012 at 02:30:47 UTC, Timon Gehr wrote:
 On 07/11/2012 04:25 AM, ixid wrote:
 in some way it sees global immutables almost as enums

This seems like a bad idea. Consistency of behaviour would seem to be a good principle to expect of a language.

You are right; this is a bug.

Has someone reported this bug? I can't seem to find it in the tracker. If not, how should I go about reporting it?
Jul 18 2012
prev sibling next sibling parent "Lemonfiend" <no email.here> writes:
On Wednesday, 18 July 2012 at 12:15:52 UTC, Lemonfiend wrote:
 On Wednesday, 11 July 2012 at 02:30:47 UTC, Timon Gehr wrote:
 On 07/11/2012 04:25 AM, ixid wrote:
 in some way it sees global immutables almost as enums

This seems like a bad idea. Consistency of behaviour would seem to be a good principle to expect of a language.

You are right; this is a bug.

Has someone reported this bug? I can't seem to find it in the tracker. If not, how should I go about reporting it?

Also, I don't think I'm clear enough about the differences between immutables, consts and enums to write a bug report about this.
Jul 18 2012
prev sibling next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Timon Gehr:

 You are right; this is a bug.

This discussion is not about an obscure language detail, it's a common situation. So if you think this is a bug, then please Timon file it in Bugzilla. Bye, bearophile
Jul 18 2012
prev sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
Timon Gehr:

 Usually bugs are reported by the guy who finds them, but here 
 you go:
 http://d.puremagic.com/issues/show_bug.cgi?id=8400

Thank you, already fixed, it seems. Even if the fix is the opposite of what I have thought (I was thinking about forbidding global immutables too to be used as compile-time constants, while this fix turns local immutables too into enums. I hope this change doesn't cause a large mess). Bye, bearophile
Jul 20 2012