Skip to content

Fix missing symbols for template alias arguments during codegen#22849

Open
oCHIKIo wants to merge 1 commit intodlang:masterfrom
oCHIKIo:fix-linker-error-22848
Open

Fix missing symbols for template alias arguments during codegen#22849
oCHIKIo wants to merge 1 commit intodlang:masterfrom
oCHIKIo:fix-linker-error-22848

Conversation

@oCHIKIo
Copy link
Copy Markdown
Contributor

@oCHIKIo oCHIKIo commented Mar 31, 2026

Fixes #22848

i discovered that the compiler was skipping code generation for symbols (like nested functions) when they were passed only as alias arguments to templates. this resulted in "undefined reference" linker errors because the backend never visited those dependencies.
this PR adds a traversal of template arguments (tiargs) to the toObjFile visitor in toobj.d. this ensures that all symbols required by a non-speculative template instantiation are correctly processed for code generation.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @oCHIKIo! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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.

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#22849"

@oCHIKIo oCHIKIo force-pushed the fix-linker-error-22848 branch from af81842 to b116364 Compare March 31, 2026 20:16
@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Mar 31, 2026

A function passed as a template parameter doesn't need code gen when it's not used, that is intentional. In the issue's test case, neither function needs code gen.

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.

Undefined reference to static function in unused mixin lambda

3 participants