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

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11094

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P2  |P3

--


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

2022-05-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11094

Ben  changed:

   What|Removed |Added

 CC||ben.james.jo...@gmail.com

--- Comment #2 from Ben  ---
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?

--


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

2014-04-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11094

Andrej Mitrovic  changed:

   What|Removed |Added

 CC||andrej.mitrov...@gmail.com

--- Comment #1 from Andrej Mitrovic  ---
Note that it is unrelated to the overloads, you could have a single opBinary to
reproduce:

-
struct Foo
{
Foo opBinary(string op)(in Foo r) if (op == "+" || op == "^")
{
return Foo();
}
}

void main()
{
const x = Foo();
auto r1 = x + Foo();
auto r2 = x ^ Foo();
}
-

--