Skip to content
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
15 changes: 15 additions & 0 deletions compiler/src/dmd/templatesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3282,6 +3282,21 @@ bool needsCodegen(TemplateInstance ti)
return false;
}

if (ti.enclosing)
{
if (auto fd = ti.enclosing.isFuncDeclaration())
{
if (auto fld = fd.isFuncLiteralDeclaration())
{
if (fld.tookAddressOf == 0 && fld.tok != TOK.reserved)
{
ti.minst = null; // mark as speculative
return false;
}
}
}
}

// This should only be called on the primary instantiation.
assert(ti is ti.inst);

Expand Down
20 changes: 20 additions & 0 deletions compiler/test/runnable/issue22848.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@"
// Test for Issue 22848
// Undefined reference to static function in unused mixin lambda

mixin template Main(alias mainFunction) {}

mixin Main!(
()
{
static bool pred(char c) => false;
accept!pred;
}
);

char accept(alias pred)() => pred(0);

void main()
{
}
"@
Loading