CLion 2018.1.2 inspection gives false error on lambda expression with template parameters
Answered
In CLion 2018.1.2 the following code causes CLion to give a "Parameter Type Mismatch" error.
e->addComponent<MockComponentOne>(
[](MockComponentOne* c){
c->x(12.0);
c->y(4.0);
});
Which it didn't in version 2018.1.1. The code compiles correctly and all test cases pass. I've uploaded a screenshot using the web form. The file name is error.png.
The signature of the addComponent method is:
template <class T> Status addComponent(std::function<void(T*)> init)
It complains that "Types: 'std::function<void(MockComponentOne*)>' and 'void(*)(MockComponentOne*)' are not compatible". Please fix. It's really annoying.
Thanks.
Please sign in to leave a comment.
It seems that it boils down to something broken in CLion 2018.1.2 related to assigning a lambda to std::function. A simple statement like:
Is underlined in red complaining that:
Even tough it compiles just fine.
Here's the entire piece of code in question. It's a lambda inside a lambda.
Thanks. Currently the regression is under development/testing: https://youtrack.jetbrains.com/issue/CPP-12919