Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix Issue 8522 - Comparison operator overloading doesn't consider the…
… qualifier of lhs
  • Loading branch information
9rnsr committed Aug 8, 2012
1 parent cef1bbf commit f6af3ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/opover.c
Expand Up @@ -809,7 +809,7 @@ Expression *BinExp::compare_overload(Scope *sc, Identifier *id)
}
else
{ TemplateDeclaration *td = s->isTemplateDeclaration();
templateResolve(&m, td, sc, loc, targsi, NULL, &args2);
templateResolve(&m, td, sc, loc, targsi, e1, &args2);
}
}

Expand All @@ -825,7 +825,7 @@ Expression *BinExp::compare_overload(Scope *sc, Identifier *id)
}
else
{ TemplateDeclaration *td = s_r->isTemplateDeclaration();
templateResolve(&m, td, sc, loc, targsi, NULL, &args1);
templateResolve(&m, td, sc, loc, targsi, e2, &args1);
}
}

Expand Down
20 changes: 20 additions & 0 deletions test/runnable/opover.d
Expand Up @@ -1001,6 +1001,25 @@ void test8133()
assert(f() == 1);
}

/**************************************/
// 8522

struct Point8522
{
bool opEquals(R)(R rhs) { return true; }
bool opEquals(R)(R rhs) const { return true; }
}

void test8522()
{
Point8522 mp;
const Point8522 cp;
assert(mp == mp);
assert(mp == cp);
assert(cp == mp); // doesn't work
assert(cp == cp); // doesn't work
}

/**************************************/

int main()
Expand All @@ -1026,6 +1045,7 @@ int main()
test4953d();
test4993();
test8133();
test8522();

printf("Success\n");
return 0;
Expand Down

0 comments on commit f6af3ce

Please sign in to comment.