dmd/compiler/test/fail_compilation/fail125.d
2024-05-03 10:52:21 +01:00

26 lines
594 B
D

/*
TEST_OUTPUT:
---
fail_compilation/fail125.d(15): Error: sequence index `[2]` is outside bounds `[0 .. 2]`
fail_compilation/fail125.d(18): Error: template instance `fail125.main.recMove!(1, a, b)` error instantiating
fail_compilation/fail125.d(25): instantiated from here: `recMove!(0, a, b)`
---
*/
template recMove(int i, X...)
{
void recMove()
{
X[i] = X[i+1];
// I know the code is logically wrong, should test (i+2 < X.length)
static if (i+1 < X.length)
recMove!(i+1, X);
}
}
void main()
{
int a, b;
recMove!(0, a, b);
}