Found this when trying to reduce another bug.
Attached problematic source.
Comment #1 by ibuclaw — 2013-04-15T03:45:59Z
Created attachment 1209
typetuple.d
Comment #2 by ibuclaw — 2013-04-15T03:46:52Z
Requires -unittest to reproduce.
Comment #3 by ibuclaw — 2013-04-15T03:51:38Z
And here is the change that dustmite made to cause the bug.
---
diff -pur bug.reduced/typetuple.d bug.test/typetuple.d
--- bug.reduced/typetuple.d 2013-04-15 11:48:35.739230767 +0100
+++ bug.test/typetuple.d 2013-04-15 11:49:13.303231268 +0100
@@ -34,7 +34,7 @@ alias GenericReplace!(T, U, TList).resul
template GenericReplace(args...)
{
-alias args[0]from;
+alias args[]from;
alias args[1]to;
alias args[2 .. $] tuple;
Comment #4 by bugzilla — 2013-10-07T00:10:09Z
The example code:
------------------
template TypeTuple(TList...)
{
alias TList TypeTuple;
}
template staticIndexOf(T, TList...)
{
enum staticIndexOf = genericIndexOf!(T, TList).index;
}
template genericIndexOf(args...)
{
alias args[0]e;
alias args[1 .. $] tuple;
alias Alias!(tuple[0]) head;
alias tuple[1 .. $] tail;
static if (isSame!(e, head))
{
enum index = 0;
}
else
{
enum next = genericIndexOf!(e, tail).index;
enum index = (next == -1) ? -1 : 1 + next;
}
}
template Replace(alias T, alias U, TList...)
{
alias GenericReplace!(T, U, TList).result Replace;
}
template GenericReplace(args...)
{
alias args[]from;
alias args[1]to;
alias args[2 .. $] tuple;
alias Alias!(tuple[0]) head;
alias tuple[1 .. $] tail;
static if (isSame!(from, head))
alias TypeTuple!(to, tail) result;
else
alias TypeTuple!(head,
GenericReplace!(from, to, tail).result) result;
}
unittest
{
static assert(Pack!(Replace!(1111, "11",
2222, 1111, 1111, 1111)).
equals!(2222, "11", 1111, 1111));
}
template Alias(a...)
{
alias a Alias;
}
template isSame(ab...)
{
static if (!__traits(compiles, expectType!ab) &&
__traits(compiles, expectBool!(ab[0] == ab[1])))
static if (!__traits(compiles) )
enum isSame = ab[0] == ab[1];
else
enum isSame = (isSame);
else
enum isSame = __traits(isSame, ab, ab);
}
template expectBool(bool b) {}
template Pack(T...)
{
template equals(U...)
{
static if (T.length == 0)
enum equals = true;
else
enum equals = isSame!(T, U) && Pack!(T[1 .. $]).equals!(U);
}
}