Skip to content

Conversation

@CyberShadow
Copy link
Member

LLM disclosure: this entire PR is AI-generated. It might be OK, or it might be slop. The fix looks sensible on the surface, and it passes the test suite, however, so does most slop in general. Still, I'd really like this bug to be fixed, so off the chance that this is actually OK, it seems worth a shot.


When matching a lambda against a delegate type like R delegate(Args) during IFTI, parameter types that resolve to TypeTuples (e.g. from AliasSeq) were not being expanded before comparing parameter counts.

This caused IFTI to fail for lambdas like (a) => a.m() when matched against R delegate(AliasSeq!S), even though explicit instantiation fun!void((a) => a.m()) worked correctly.

The fix resolves and expands TypeTuple parameters before comparing counts, similar to what TypeFunction.typeSemantic does, but only for parameters that don't rely on template parameters being deduced.

🤖 Generated with Claude Code

When matching a lambda against a delegate type like `R delegate(Args)`
during IFTI, parameter types that resolve to TypeTuples (e.g. from
AliasSeq) were not being expanded before comparing parameter counts.

This caused IFTI to fail for lambdas like `(a) => a.m()` when matched
against `R delegate(AliasSeq!S)`, even though explicit instantiation
`fun!void((a) => a.m())` worked correctly.

The fix resolves and expands TypeTuple parameters before comparing
counts, similar to what TypeFunction.typeSemantic does, but only for
parameters that don't rely on template parameters being deduced.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @CyberShadow!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#22262"

Type pt = pto.type;
if (!reliesOnTemplateParameters(pt, parameters[inferStart .. parameters.length]))
{
pt = pt.syntaxCopy().typeSemantic(e.loc, sc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about that syntaxCopy call doesn't seem necessary.

Needs further review.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude says:

syntaxCopy is needed because typeSemantic may modify the type in-place
(setting deco), and we don't want to contaminate the template's
parameter list for future instantiations.

@CyberShadow CyberShadow marked this pull request as ready for review December 19, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants