Stewart Gordon <> changed:

           What    |Removed                     |Added
                 CC|                            |
           Platform|Other                       |All

--- Comment #1 from Stewart Gordon <>  2009-07-17 10:24:56 PDT ---
(In reply to comment #0)
> Despite being redundant, my main gripe with opIndexAssign is that it can even
> get in the way. For instance:

opIndexAssign isn't redundant, just as property setters aren't redundant.

>     // This requires opIndexAssign, but for no good reason
>     //a[1, 1] = 42;

Given that opIndexAssign doesn't occur in your code, removing opIndexAssign
from the language isn't going to magically make this work.

Here's the compiler output (DMD 2.031 Win):
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz3188.d
bz3188.d(28): Error: operator [] assignment overload with opIndex(i, value)
illegal, use opIndexAssign(value, i)

Really, the problem is that opIndex is only meant to work on op=, ++ and --,
not = itself.
"Note: To use array index overloading with the op=, ++, or -- operators, have
the opIndex function return a reference type. This reference is then used as
the lvalue for those operators."

The way resolving = ought to work:
- first look for a matching opIndexAssign
- if none, look for an opIndex with a ref return

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to