This code: ``` import std.typecons; void foo(alias fields)() { foreach(i, field; fields) { enum string a = fields[i]; // OK enum string b = field; // not OK with 2.069.2 ??? } } void main() { foo!(tuple("H", "I", "J"))(); } ``` Builds with DMD 2.068.2. Fails with DMD 2.069.2, and fails with DMD 2.070.2: foreachTuple.d(6): Error: variable field cannot be read at compile time foreachTuple.d(6): Error: variable field cannot be read at compile time foreachTuple.d(6): Error: variable field cannot be read at compile time foreachTuple.d(11): Error: template instance foreachTuple.foo!(Tuple("H", "I", "J")) error instantiating I believe this is a regression. (I am not sure if this is duplicate or related to https://issues.dlang.org/show_bug.cgi?id=15740 )
AFAIK foreach isn't implemented in phobos, but a feature of the compiler - so it seems to me to be an issue with dmd.
Introduced in: https://github.com/dlang/dmd/pull/4797
https://github.com/dlang/dmd/pull/5977
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/60390bd21a45479b6377751fef4be40159effe0a fix Issue 15780 - [REG2.069] CTFE foreach fails with tuple https://github.com/dlang/dmd/commit/4a108b3e8b9192dde15ffb513f34df7e3bc62d64 Merge pull request #6000 from MartinNowak/fix15780 fix Issue 15780 - [REG2.069] CTFE foreach fails with tuple
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/60390bd21a45479b6377751fef4be40159effe0a fix Issue 15780 - [REG2.069] CTFE foreach fails with tuple https://github.com/dlang/dmd/commit/4a108b3e8b9192dde15ffb513f34df7e3bc62d64 Merge pull request #6000 from MartinNowak/fix15780
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/60390bd21a45479b6377751fef4be40159effe0a fix Issue 15780 - [REG2.069] CTFE foreach fails with tuple https://github.com/dlang/dmd/commit/4a108b3e8b9192dde15ffb513f34df7e3bc62d64 Merge pull request #6000 from MartinNowak/fix15780