May 24, 2019
https://issues.dlang.org/show_bug.cgi?id=19900

          Issue ID: 19900
           Summary: Rewrites for unary index operator not done per the
                    spec
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: qs.il.paperinik@gmail.com

The rewrites for unary operator before a slice expression reject valid code. Only the part tagged with "For backward compatibility" properly compiles.

struct S
{
    static struct Slice { size_t l, u; }
    Slice opSlice(size_t l, size_t u) { return Slice(l, u); }
    S opIndexUnary(string op)(Slice slice)
    {
        return S.init;
    }
}

unittest
{
    S a;
    S b = ++a[1 .. 2]; // fails
    S c = a.opIndexUnary!("++")(a.opSlice(i, j));
}

--