DMD 2.059beta (not head), on a 64-bit GNU/Linux ---------------->8---------------->8---------------- import std.typecons; import std.stdio; void main() { alias Tuple!(int, long, float) TL; foreach (i, T; TL) writefln("TL[%d] = ", i, typeid(T)); } ----------------8<----------------8<---------------- I get: _field_field_0 Internal error: e2ir.c 688 source (under the section 'Looping'): http://dlang.org/tuple.html The code in that section is also wrong and doesn't compile. The following gives the correct output: ---------------->8---------------->8---------------- import std.typecons; import std.typetuple; import std.stdio; void main() { Tuple!(int, long, float) TL; foreach (i, T; TL) writefln("TL[%d] = %s", i, typeid(T)); alias TypeTuple!(3, 7L, 6.8) ET; foreach (i, E; ET) writefln("ET[%d] = %s", i, E); ----------------8<----------------8<----------------
This is a regression (an error was issued in 2.057, the ICE was introduced in 2.058).
Maybe this is bug 7851? (Which would make this a Phobos regression, even though it's a compiler bug)
This reduces to: template TypeTuple(TList...) { alias TList TypeTuple; } struct Tuple(Specs...) { TypeTuple!(int, long, float) mem; alias Identity!(mem[0]) _0; alias Identity!(mem[1]) _1; alias Identity!(mem[2]) _2; alias mem this; enum length = mem.length; } private template Identity(alias T) { alias T Identity; } void main() { alias Tuple!(int, long, float) TL; foreach (i; TL) { } }
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/7e3a2205fca61512dd4245b939d4f7b4e7334419 fix Issue 7851 - Internal error: e2ir.c 688
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/cc8389aa19471499b25abf85e39d55f884b0bc85 fix Issue 7851 - Internal error: e2ir.c 688