import std.algorithm: map; import std.typecons: tuple; int foo() { return 0; } void main() { auto bars = map!(n => tuple(foo(), n))([10]); auto spam = bars.front[1]; } Compiling with: dmd -O test.d DMD 2.058head gives: Error: variable __tup818 used before set Note the lack of error line number.
It is tuple + indexing + optimization bug. Workaround: void main() { auto bars = map!(n => tuple(foo(), n))([10]); auto spam_tup = bars.front;//[1]; // save whole tuple temporarily auto spam = spam_tup[1]; // get an element of tuple } It will be fixed by merging: https://github.com/D-Programming-Language/dmd/pull/609
Works for me, presumably fixed by the fix to issue 4940 https://github.com/D-Programming-Language/dmd/commit/d6ede2edc28c94b6b3372eb1301cf300b0860eb6