Skip to content

Nested struct inside a templated class doesn't provide completions #1249

@ionagamed

Description

@ionagamed

Using a nested struct inside of a templated struct inside another templated function does not provide code completions:

template <typename T>
struct Foo {
    struct Bar {
        int Field;
    };
};

template <typename AnotherT>
void func() {
    typename Foo<AnotherT>::Bar bar;
    bar.|  // expecting to have "Field" as a possible completion here.
           // Other features also don't work, e.g. I can write "bar.AnotherField"
           // and it won't highlight it as an error.
}

Using int instead of AnotherT in bar definition works as expected:

template <typename T>
struct Foo {
    struct Bar {
        int Field;
    };
};

template <typename AnotherT>
void func() {
    //           vvv
    typename Foo<int>::Bar bar;
    bar.|  // has "Field" as a completion suggestion.
}

Logs

Unfortunately my only current clangd install is on a dev machine with company code which I can't share. Let me know if logs are absolutely needed, I'll try to fire up an unrelated clangd to test this behavior.

System information

Output of clangd --version:

 $ ~/clangd_14.0.3/bin/clangd --version
clangd version 14.0.3 (https://github.com/llvm/llvm-project 1f9140064dfbfb0bbda8e51306ea51080b2f7aac)
Features: linux+grpc
Platform: x86_64-unknown-linux-gnu

Editor/LSP plugin: VSCode clangd v0.1.21

Operating system:

 $ cat /etc/issue
Ubuntu 20.04.3 LTS \n \l

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions