struct ValueImpl
{
    static immutable(int) getValue()
    {
        return 42;
    }
}

struct ValueUser
{
    ValueImpl m_valueImpl;
    alias m_valueImpl this;
}

void main(string[] args)
{
    static assert(ValueImpl.getValue() == 42);
    static assert(ValueUser.getValue() == 42); // (1)
}

(1) Doesn't compile. Error: variable m_valueImpl cannot be read at compile time

To use alias this for composition, it would be nice if the compile-time evaluable members of the aliased object would remain compile-time evaluable even when used through an alias. Is the current behavior defined by the language or is it due to the compiler (DMD) implementation?

Reply via email to