[Issue 21787] Operator Overload by a Variable not detected

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 1 10:57:20 UTC 2021


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

Manfred Nowak <svv1999 at hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Manfred Nowak <svv1999 at hotmail.com> ---
Specs.20.8|1 require `opIndex` to be a method. Therefore this is not a bug, but
an enhancement.

Although that requirement can be satisfied by declaring

  class C{
    bool delegate( int) opIndexVar;
    bool opIndex( int arg){
      return opIndexVar( arg);
    }
  }

the result would be an additional call unless the machine code generator
optimizes that call away.

--


More information about the Digitalmars-d-bugs mailing list