[Issue 15582] New: Slice returned by opSlice() not accepted as lvalue

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jan 18 11:22:35 PST 2016


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 at puremagic.com
          Reporter: schuetzm at 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
}

--


More information about the Digitalmars-d-bugs mailing list