[Issue 15780] New: CTFE foreach fails with tuple
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Mar 9 02:17:31 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15780
Issue ID: 15780
Summary: CTFE foreach fails with tuple
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: jbc.engelen at gmail.com
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 )
--
More information about the Digitalmars-d-bugs
mailing list