diff --git a/src/mtype.c b/src/mtype.c index de48960f1d3e..cc225fc63d93 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -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; } } diff --git a/src/template.c b/src/template.c index 46ef9032720b..652e1eade953 100644 --- a/src/template.c +++ b/src/template.c @@ -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; diff --git a/test/runnable/overload.d b/test/runnable/overload.d index c9d04d6f7ecb..db4243b593cf 100644 --- a/test/runnable/overload.d +++ b/test/runnable/overload.d @@ -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 @@ -1068,6 +1084,7 @@ int main() test10658a(); test10658b(); test11785(); + test11915(); test11916(); printf("Success\n");