[Issue 20399] opIn deprecation warning should point to where opIn is defined, not where it is used.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 7 08:07:58 UTC 2020


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |simen.kjaras at gmail.com
         Resolution|INVALID                     |---

--- Comment #4 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
You should only get the error if opIn is being used for operator overloading,
yes.

However, the error message should at the very least mention the location where
opIn is defined, as that's where the code change will need to happen. We can
expect that if someone tries to use opIn with operator overloading, opIn has
been written with that in mind.

Now, that means the error message should be fixed, such that this program

struct S {
    void opIn(S s) { }
}

unittest {
    S s1, s2;
    s1 in s2;
}

gives this error message:

foo.d(7) Deprecation: using opIn for operator overloading is deprecated. Call
it as s1.opIn(s2) instead, or change the definition to opBinary(string op)(...)
if (op == "in").
foo.d(2) opIn is defined here

--


More information about the Digitalmars-d-bugs mailing list