Summary: UFCS and operator overloading
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from 2012-05-08 01:08:27 PDT ---
According to TDPL (p. 388, Table 12.1)
a + b
is rewritten to
a.opBinary!("+")(b) or b.opBinaryRight!("+")(a)

Considering operator overloading together with UFCS leads to the following
wrong behavior.

struct Foo {}

Foo opBinary(string op)(Foo lhs, Foo rhs) if (op == "+")
    return Foo.init;

    Foo a, b;
    a + b; // fails to compile even though it should

If a + b is rewritten to a.opBinary!("+")(b) first, then UFCS should rewrite it
further to opBinary!("+")(a,b). But it seems UFCS is not considered. UFCS
should be carried out when the operator is being rewritten.

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

Reply via email to