https://issues.dlang.org/show_bug.cgi?id=18945
Issue ID: 18945 Summary: immutable variable is used as if it's an enum Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Keywords: CTFE Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: simen.kja...@gmail.com unittest { immutable n = __ctfe ? 1 : 2; int[n] a; assert(a.length == n); } The above assert fails - the value of n is calculated using CTFE for the length of a, and is thus set to 1. Then, at runtime, the value of n is set to 2, and the assert fails. It seems to me the issue is that the variable n is being used as a compile-time constant. The expected behavior is an error message along the lines of 'variable n cannot be read at compile time'. --