Skip to content

Implement template parameter resolution for type completions#797

Open
bangbangsheshotmedown wants to merge 1 commit intodlang-community:masterfrom
bangbangsheshotmedown:templates
Open

Implement template parameter resolution for type completions#797
bangbangsheshotmedown wants to merge 1 commit intodlang-community:masterfrom
bangbangsheshotmedown:templates

Conversation

@bangbangsheshotmedown
Copy link
Copy Markdown

- vibe coded -

Implement template parameter resolution for type completions

When completing members of templated types (e.g., Data!Vec2), DCD now resolves template parameters (T) to their concrete arguments (Vec2), providing accurate type information for autocomplete suggestions.

Changes:

  • Add templateInstantiation lookup kind to track template instantiations
  • Parse template arguments from TypeIdentifierPart AST nodes
  • Store template arguments in TypeLookup for use in type resolution
  • Implement resolveTemplateInstantiation() to substitute template parameters
  • Add tc_templates test case to verify template resolution

Fixes: Code completion for templated structs/classes where members use template parameters in their type declarations.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 7, 2026

Thanks for your Pull Request and making D better!

This comment will automatically be updated to summarize some statistics in a few minutes.

@bangbangsheshotmedown
Copy link
Copy Markdown
Author

Failures seems unrelated to the PR

@@ -0,0 +1,9 @@
identifiers
Vec2 h
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this does not seem to be valid D code:

struct Data(T) {
    T value;
}


struct Vec2{}

void main() {
    Data!Vec2 mydata;

    pragma(msg, mydata.Vec2);
}

gives

a.d(11): Error: more initializers than fields (0) of `Vec2`
    pragma(msg, mydata.Vec2);
                      ^
a.d(11):        while evaluating `pragma(msg, mydata.Vec2)`
    pragma(msg, mydata.Vec2);
    ^

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oops i add the wrong file

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.

2 participants