April 01, 2021
https://issues.dlang.org/show_bug.cgi?id=21787

          Issue ID: 21787
           Summary: Operator Overload by a Variable not detected
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: svv1999@hotmail.com

void main(){
  class C{
    bool delegate( int) opIndex;
  }
  auto var= new C;
  assert( var[ 0]); // Error: no `[]` operator overload for type `main.C`
}

In 20. the specs declare overloads to be rewrites "into calls to specially named members". In 20.8.1 the specs declare `opIndex` to be such a special name. No further restriction on the type of that member is given.

The code above declares `opIndex` to be a variable for a delegate, but compilation is refused.

Therefore either the specs are not complete or the code above should compile: code should even then compile, when the type of that variable is a class containing an appropriate overload for a call.

--