Skip to content

Commit 9bb4520

Browse files
committed
clean up opOverloadBinary fixes
1 parent 0a6bffe commit 9bb4520

File tree

2 files changed

+8
-36
lines changed

2 files changed

+8
-36
lines changed

compiler/src/dmd/opover.d

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -549,49 +549,20 @@ Expression opOverloadBinary(BinExp e, Scope* sc, Type[2] aliasThisStop)
549549
AggregateDeclaration ad1 = isAggregate(e.e1.type);
550550
AggregateDeclaration ad2 = isAggregate(e.e2.type);
551551

552-
553552
// Try opBinary and opBinaryRight
554553
Dsymbol s = search_function(ad1, Id.opBinary);
555554

556-
if (s)
555+
if (s && !(s.isTemplateDeclaration() || s.isOverloadSet))
557556
{
558-
if (OverloadSet os = s.isOverloadSet())
559-
{
560-
/*
561-
//printf("opBinary is an overload set\n");
562-
//multiple overloads in different scopes
563-
auto dti = new DotTemplateInstanceExp(e.loc, e.e1, Id.opBinary, opToArg(sc, e.op));
564-
//dtitype = new TypeIdentifier(Loc.initial, ttp.ident);
565-
if (!findTempDecl(dti, sc))
566-
{
567-
.error(e.loc, "Couldn't find the template declaration for opBinary");
568-
return ErrorExp.get();
569-
}
570-
s = dti.ti.tempdecl;
571-
//printf("found temp decl in the overload set: %s\n", s.toChars);
572-
*/
573-
s = os;
574-
}
575-
else if (!s.isTemplateDeclaration())
576-
{
577-
error(e.e1.loc, "`%s.opBinary` isn't a template", e.e1.toChars());
578-
return ErrorExp.get();
579-
}
557+
error(e.e1.loc, "`%s.opBinary` isn't a template", e.e1.toChars());
558+
return ErrorExp.get();
580559
}
581560

582561
Dsymbol s_r = search_function(ad2, Id.opBinaryRight);
583-
//TODO same check for opBinaryRight
584-
if (s_r)
562+
if (s_r && !(s_r.isTemplateDeclaration() || s_r.isOverloadSet()))
585563
{
586-
if (OverloadSet os = s_r.isOverloadSet())
587-
{
588-
s_r = os;
589-
}
590-
else if (!s_r.isTemplateDeclaration())
591-
{
592-
error(e.e2.loc, "`%s.opBinaryRight` isn't a template", e.e2.toChars());
593-
return ErrorExp.get();
594-
}
564+
error(e.e2.loc, "`%s.opBinaryRight` isn't a template", e.e2.toChars());
565+
return ErrorExp.get();
595566
}
596567
if (s_r && s_r == s) // https://issues.dlang.org/show_bug.cgi?id=12778
597568
s_r = null;

compiler/test/runnable/test21429.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ struct AssignOverloads
8787
}
8888

8989

90-
void main(){
90+
void main()
91+
{
9192

9293
T t;
9394
string s = t.x();

0 commit comments

Comments
 (0)