www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - constant bug?

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
Apr 06 2007