Oddly, it compiles if you commment out the ; -- the foreach has to be non-empty. Behaviour is quite odd; if there are several items in the tuple, it will work if you don't use the whole tuple; eg Types[0..$-1] and Types[1..$] will work. So it sounds like some kind of memory corruption/unterminated string or similar.
Possibly the root cause of some of the bugs in issue 1298.
========
bug.d(9): Error: cannot evaluate foo() at compile time
---
int foo(Types...)() {
foreach(T; Types) {
; // will compile if you remove this line
}
return 0;
}
const int q = foo!("")();
Comment #1 by clugdbug — 2009-02-03T08:18:08Z
This workaround for this bug has changed. On 1.039, it now fails even if you comment out the marked line. But it compiles if you add [] to the string.
int foo(Types...)() {
foreach(T; Types) {
;
}
return 0;
}
const int q = foo!("abc"[])(); // OK