www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15582] New: Slice returned by opSlice() not accepted as lvalue

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

          Issue ID: 15582
           Summary: Slice returned by opSlice() not accepted as lvalue
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schuetzm gmx.net

I believe this should work:

struct S {
    int[10] data;
    auto opSlice() { return data[]; }
}

void main() {
    S s;
    s[] = 10;   // Error: s[] is not an lvalue
    s[][] = 10; // works
}

--
Jan 18 2016