Bug 15780 – [REG2.069] CTFE foreach fails with tuple

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-09T10:17:00Z
Last change time
2016-11-04T09:04:54Z
Assigned to
nobody
Creator
jbc.engelen

Comments

Comment #0 by jbc.engelen — 2016-03-09T10:17:31Z
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 )
Comment #1 by greeenify — 2016-03-12T16:57:40Z
AFAIK foreach isn't implemented in phobos, but a feature of the compiler - so it seems to me to be an issue with dmd.
Comment #2 by k.hara.pg — 2016-05-13T22:31:39Z
Comment #3 by bugzilla — 2016-07-28T08:29:53Z
Comment #4 by github-bugzilla — 2016-08-02T11:02:58Z
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
Comment #5 by github-bugzilla — 2016-09-19T23:46:47Z
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
Comment #6 by github-bugzilla — 2016-11-04T09:04:54Z
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