[Issue 4041] Error with ref or auto ref return from opOpAssign

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 20 02:22:49 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4041


Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k.hara.pg at gmail.com


--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2011-06-20 02:17:53 PDT ---
Trivial fix of sample code:
----
struct Foo
{
    int x;

    ref Foo opOpAssign(string op)(ref Foo f) if(op == "+")  // <- "+="
    {
        x += f.x;
        return this;
    }
}
void main()
{
    Foo f1 = Foo(1);
    Foo f2 = Foo(2);
    f2 += f1;
}
----

And, on dmd 2.054 (d36b3b12fc4814e59f3a0d680b8700e787b1ceff) this code has
passed to compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list