On Friday, 21 February 2014 at 14:14:14 UTC, anonymous wrote:
Not sure if this should compile. n is a run-time value. It just
happens that it can be CTFE'd. A more problematic case:
---
void main()
{
        immutable n = __ctfe ? 1 : 2;
        int[n] a;
        assert(a.length == n); // fails, wat
}

ie, seeing the declaration 'int[n] a;' one should not assume a.length is same as 'n' at runtime. I would rather prefer getting a compilation error that n is not known at compile time and hence array declaration failed.

If this is eligible for a bugzilla, it is okay. Otherwise, I am very disappointed.

Reply via email to