[Issue 11094] Disuniform error messages with overloaded + and ^ operators

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 26 20:31:49 UTC 2022


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

Ben <ben.james.jones at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ben.james.jones at gmail.com

--- Comment #2 from Ben <ben.james.jones at gmail.com> ---
I took a look at this, and the difference seems to be related to the extra
check(s) added at the end of the expressionsem visitors for AddExp vs XorExp:

//in xor only
if (exp.checkIntegralBin() || exp.checkSharedAccessBin(sc))
    return setError();


A couple of questions.  This happens earlier in the visitor:

Expression e = exp.op_overload(sc);
if (e)
{
    result = e;
    return;
}


I assume e is null if the op overload doesn't apply (in this case there are
constness issues), but putting an error in opover.visitBin seems like maybe the
wrong fix?

Those extra checks make sense for xor, is it worth trying to add a supplemental
error or something that sees if they tried to do op overloading?

There's a TON of duplication between the addexp and xorexp visitors in
expressionsem, and I assume probably with most binop visitors.  Is it worth
trying to refactor to reduce the duplication?

--


More information about the Digitalmars-d-bugs mailing list