[Issue 15355] unstable operator overloading with comma expression

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Dec 6 06:50:06 PST 2015


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

Infiltrator <lt.infiltrator at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lt.infiltrator at gmail.com

--- Comment #1 from Infiltrator <lt.infiltrator at gmail.com> ---
This might be surprising behaviour; but I think that it fits with what the
comma operator does.

(a, b) gets evaluated as do a, discard, do b and return.

So, in this case:
(1, s2[0]) = 1
Evaluate 1 and discard just does nothing.  Evaluate s2[0] and return gives us a
ref to s2.y.  Only then does the = 1 take effect, so we end up with (ref to
s2.y) = 1.

So I don't think that there is actually a problem with the operator overloading
in this case.

As for whether or how this quirk should be fixed, I'm afraid that I can't
really say.

--


More information about the Digitalmars-d-bugs mailing list