Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression 2.061] Issue 9410 - Wrong selection for function overload #1571

Merged
merged 1 commit into from Jan 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/mtype.c
Expand Up @@ -6081,25 +6081,6 @@ MATCH TypeFunction::callMatch(Expression *ethis, Expressions *args, int flag)
new IntegerExp(0, ((StringExp *)arg)->len,
Type::tindex));
}
else if (ta && ta->implicitConvTo(tprm))
{
goto Nomatch;
}
else if (arg->op == TOKstructliteral)
{
match = MATCHconvert;
}
else if (arg->op == TOKcall)
{
CallExp *ce = (CallExp *)arg;
if (ce->e1->op == TOKdotvar &&
((DotVarExp *)ce->e1)->var->isCtorDeclaration())
{
match = MATCHconvert;
}
else
goto Nomatch;
}
else
goto Nomatch;
}
Expand Down
16 changes: 1 addition & 15 deletions src/template.c
Expand Up @@ -1588,21 +1588,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec
if (m && (fparam->storageClass & (STCref | STCauto)) == STCref)
{ if (!farg->isLvalue())
{
if (farg->op == TOKstructliteral)
m = MATCHconvert;
else if (farg->op == TOKcall)
{
CallExp *ce = (CallExp *)farg;
if (ce->e1->op == TOKdotvar &&
((DotVarExp *)ce->e1)->var->isCtorDeclaration())
{
m = MATCHconvert;
}
else
goto Lnomatch;
}
else
goto Lnomatch;
goto Lnomatch;
}
}
if (m && (fparam->storageClass & STCout))
Expand Down
14 changes: 14 additions & 0 deletions test/runnable/overload.d
Expand Up @@ -94,13 +94,27 @@ void test8943()
static assert(is(P[0] == S));
}

/***************************************************/
// 9410

struct S {}
int foo(float f, ref S s) { return 1; }
int foo(float f, S s) { return 2; }
void test9410()
{
S s;
assert(foo(1, s ) == 1); // works fine. Print: ref
assert(foo(1, S()) == 2); // Fails with: Error: S() is not an lvalue
}

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

int main()
{
test7418();
test7552();
test8943();
test9410();

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