Skip to content

[clangd] [Signature help] [C++23] Parameter hints do not appear for static operator (and some obscure interaction with templates) #196153

@timon-ul

Description

@timon-ul

In the following example code I do not get any parameter hints for the operator, but if I manually type in true clangd recognizes that I am calling the operator.

Details
struct Abc {
    static void operator()(bool a) {}
};

void test() {
    Abc abc;
    abc(^);
}
Image

If I remove the static from the operator definition I do get the paramtere hints.

Details
struct Abc {
    void operator()(bool a) {}
};

void test() {
    Abc abc;
    abc(^);
}
Image

As straight forward as this bug seems to be, I stumbled upon some more odd behaviour. Consider now me using 2 parameters, this still does not work with static as you can see here.

Details
struct Abc {
    static void operator()(bool a, bool b) {}
};

void test() {
    Abc abc;
    abc(^);
}
Image

But if I now template my operator it does work.

Details
struct Abc {
    template <typename T>
    static void operator()(T a, bool b) {}
};

void test() {
    Abc abc;
    abc(^);
}
Image

The odd part here is that I need 2 parameters for my operator, because the templated version with only 1 parameter does not work.

Details
struct Abc {
    template <typename T>
    static void operator()(T a) {}
};

void test() {
    Abc abc;
    abc(^);
}
Image

Also it is important that the template type is used in the parameters, otherwise it does not work.

Details
struct Abc {
    template <typename T>
    static void operator()(bool a, bool b) { T c; }
};

void test() {
    Abc abc;
    abc(^);
}
Image

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions