[Issue 12927] New: Can't get at compile-time the immutable field of a struct instance in a TypeTuple
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jun 15 15:29:07 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12927
Issue ID: 12927
Summary: Can't get at compile-time the immutable field of a
struct instance in a TypeTuple
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Keywords: rejects-valid
Severity: regression
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I am not fully sure this code is valid, but this used to work until recently:
alias TypeTuple(T...) = T;
struct Foo {
int a;
immutable int b;
}
struct Bar {
auto foos = TypeTuple!(Foo(10, 20), Foo(10, 20));
void bar() {
enum i = 1;
enum r = foos[i].b;
}
}
void main() {}
With dmd 2.066alpha it gives:
temp.d(10,18): Error: value of 'this' is not known at compile time
I use this idiom to have struct instances with some mutable fields and with
some "enum" fields.
--
More information about the Digitalmars-d-bugs
mailing list