www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15026] New: cannot array assign to a slice return value

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

          Issue ID: 15026
           Summary: cannot array assign to a slice return value
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
int[] bar()
{
    return null;
}

void test()
{
    bar() = 2;
}
CODE
----
Error: bar() is not an lvalue
----

Even more annoying with opSlice.

cat > bug.d << CODE
struct Foo
{
    int[] opSlice()
    {
        return null;
    }
}

void test()
{
    Foo foo;
    foo[] = 2;
}
CODE
----
Error: foo[] is not an lvalue
----

Seems like the lvalue check should be done after array assignments are lowered.

--
Sep 07 2015