Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1571 from 9rnsr/fix9410

[Regression 2.061] Issue 9410 - Wrong selection for function overload
  • Loading branch information...
commit e7d4abc28f77ba7a2771003fe13f56efa94e0f3f 2 parents d219ea1 + ee8cf83
@WalterBright WalterBright authored
Showing with 15 additions and 34 deletions.
  1. +0 −19 src/mtype.c
  2. +1 −15 src/template.c
  3. +14 −0 test/runnable/overload.d
View
19 src/mtype.c
@@ -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;
}
View
16 src/template.c
@@ -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))
View
14 test/runnable/overload.d
@@ -95,12 +95,26 @@ void test8943()
}
/***************************************************/
+// 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;
Please sign in to comment.
Something went wrong with that request. Please try again.