[Issue 12927] 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
Mon Jun 16 07:40:23 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12927

--- Comment #2 from bearophile_hugs at eml.cc ---
(In reply to Kenji Hara from comment #1)
> In 2.063 and earlier, the code had been incorrectly accepted.
> 
> Bar.foos is an instance field, so cannot evaluate it without valid 'this'
> expression.

I see.

And is it right to reject this too:


alias TypeTuple(T...) = T;
struct Foo {
    int a;
    immutable int b;
}
__gshared foos = TypeTuple!(Foo(10, 20), Foo(10, 20));
struct Bar {
    void bar() {
        enum i = 1;
        enum r = foos[i].b;

    }
}
void main() {}

dmd 2.066alpha gives:

test.d(6): Error: static variable _foos_field_1 cannot be read at compile time

--


More information about the Digitalmars-d-bugs mailing list