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

Nick Treleaven <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Nick Treleaven <[email protected]> ---
> It works with tuples

I was a bit confused how that applied to runtime data until I thought of a type
sequence instance:

auto f(T...)(T s)
{
    alias a = s[0];
    a = 3; // OK, s is an lvalue sequence
    return s[0];
}
static assert(f(1) == 3);

This is a bit surprising. So I suppose your example aliasing a compile-time
known element of a static array of runtime data could also work. But I noticed
aliasing a struct .tupleof doesn't work:

struct S {int i;}
auto f(){
    S s;
    s.tupleof[0] = 5; // OK, .tupleof appears to be an lvalue sequence
    alias seq = s.tupleof; // error
    alias a = s.tupleof[0]; // error
    alias a = s.i; // OK
    a = 4; // Error: need `this` for `i` of type `int`
    return s.i;
}
static assert(f(1) == 5);

--

Reply via email to