----
template Tuple(A...)
{
alias A Tuple;
}
alias Tuple!("one", "two") tuple;
size_t foo()
{
return 1;
}
static assert(tuple[foo()] == "two");
void main() {}
----
Output:
test.d(24): Error: Integer constant expression expected instead of foo()
Bogus output when the tuple is indexed in msg pragma (introducing an intermediate const does not help):
----
template Tuple(A...)
{
alias A Tuple;
}
alias Tuple!("one", "two") tuple;
size_t foo()
{
return 1;
}
const i = foo();
pragma(msg, tuple[i]); // fails
// static assert(tuple[i] == "two"); // while this passes
void main() {}
----
Output:
test.d(24): Error: Integer constant expression expected instead of foo()
one
IIRC, a similar bug was posted long time ago. If anybody can find it, please mark it a duplicate.