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

Fix bugzilla 24883 - Speculative template overload error escapes with… #17096

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion compiler/src/dmd/templatesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,13 @@ extern (D) MATCHpair deduceFunctionTemplateMatch(TemplateDeclaration td, Templat
//printf("farg = %s %s\n", farg.type.toChars(), farg.toChars());

RootObject oarg = farg;
if ((fparam.storageClass & STC.ref_) && (!(fparam.storageClass & STC.auto_) || farg.isLvalue()))

if (farg.isFuncExp())
{
// When assigning an untyped (void) lambda `x => y` to a `(F)(ref F)` parameter,
// we don't want to deduce type void creating a void parameter
}
else if ((fparam.storageClass & STC.ref_) && (!(fparam.storageClass & STC.auto_) || farg.isLvalue()))
{
/* Allow expressions that have CT-known boundaries and type [] to match with [dim]
*/
Expand Down
6 changes: 6 additions & 0 deletions compiler/test/compilable/rvalueref.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ struct AS

void popFront(ref string) { }
static assert(!is(typeof((R r) => r.popFront)));

// https://issues.dlang.org/show_bug.cgi?id=24883
int toString(Writer)(ref Writer sink) => 3;
int toString(void delegate(scope const(char)[]) sink) => 4;
void put() {}
static assert(toString(dst => put()) == 4);
Loading