Skip to content

Commit

Permalink
fix Issue 11915 - Inconsistent overload resolution behaviour between …
Browse files Browse the repository at this point in the history
…`ref` and `out`
  • Loading branch information
9rnsr committed Oct 26, 2014
1 parent 868bc03 commit f536d3f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/mtype.c
Expand Up @@ -5873,7 +5873,13 @@ MATCH TypeFunction::callMatch(Type *tthis, Expressions *args, int flag)
goto Nomatch;
}
else if (p->storageClass & STCout)
{ if (m && !arg->isLvalue())
{
if (m && !arg->isLvalue())
goto Nomatch;

Type *targb = targ->toBasetype();
Type *tprmb = tprm->toBasetype();
if (!targb->constConv(tprmb))
goto Nomatch;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/template.c
Expand Up @@ -2054,7 +2054,7 @@ void functionResolve(Match *m, Dsymbol *dstart, Loc loc, Scope *sc,
if (tiargs && tiargs->dim > 0)
return 0;

//printf("fd = %s %s\n", fd->toChars(), fd->type->toChars());
//printf("fd = %s %s, fargs = %s\n", fd->toChars(), fd->type->toChars(), fargs->toChars());
m->anyf = fd;
TypeFunction *tf = (TypeFunction *)fd->type;

Expand Down
17 changes: 17 additions & 0 deletions test/runnable/overload.d
Expand Up @@ -1008,6 +1008,22 @@ void test11785()
input.read(v);
}

/***************************************************/
// 11915

int f11915( int) { return 1; }
int f11915(ref int) { return 2; }

int g11915( int) { return 1; }
int g11915(out int) { return 2; }

void test11915()
{
const int n = 1;
assert(f11915(n) == 1);
assert(g11915(n) == 1);
}

/***************************************************/
// 11916

Expand Down Expand Up @@ -1068,6 +1084,7 @@ int main()
test10658a();
test10658b();
test11785();
test11915();
test11916();

printf("Success\n");
Expand Down

0 comments on commit f536d3f

Please sign in to comment.