April 06, 2007
Why doesn't this code compile?

const int a = 0;
const int foo = 4;
const int[1] bar = [foo * 2];
const int zap = (1 << bar[a]); // commented out compiles fine

I get the following error:

test.d(3): Error: non-constant expression foo * 2
test.d(4): Error: non-constant expression 1 << foo * 2