New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display argument errors for non-overloaded functions in C++. #2621
Comments
Could you please include a reproducible minimal test case including what you did, what you expected to happen (assuming your feature request is implemented) and what actually happens. FWIW our diagnostics reporting come from libclang, so there is likely no way for YCM to provide the feature, but it isn't completely clear what scenario you're describing. Thanks. |
When displaying errors for the following code: #include <memory>
struct A {};
void f(A* ptr)
{}
int main()
{
std::unique_ptr<A> a(new A);
// Error:
f(a);
// Should be:
f(a.get());
} It displays on the erroneous line: But when I compile with
So, in these cases, where the function is not overloaded, or there is only one overloaded function with the same number of arguments, the error shown inside Vim should be something like the |
If you put the cursor on the line with the error and type https://github.com/Valloric/YouCompleteMe#the-ycmshowdetaileddiagnostic-command |
Yes. But that is not the point. I argue that, in this specific common cases, the note is a more useful short message than the error. |
Thanks, i understand. To be honest, I'm not sure if there is a programmatic way for us to know that, however. |
I've given some thought to this, but unfortunately think there is nothing we can do to help this particular case. Libclang's API and thus clang completer can indeed differentiate between This however is a terrible idea in case of templates. A simple error with template objects, methods and others usually produces a comprehensible error message in the first few lines and then a ton of notes about every possible choice for the Let's compile the following C++ file: #include <functional>
#include <vector>
int main(void) {
std::hash< std::vetor< std::string > > a;
return 0;
} G++ errors:
Clang however is much smarter in this case:
Clang++ errors:
Templates can produce a flood of weird combinatioin of errors or warnings and messages. For a bad case of non-templated code errors take a look at this stackoverflow post. |
Like I mentioned in the previous comment, it would be impossible to selectively give priority to |
Issue Prelude
Please complete these steps and check these boxes (by putting an
x
insidethe brackets) before filing your issue:
[Frequently Asked Questions][faq] section.
about to report and couldn't find an answer to my problem. ([Example Google
search.][search])
vim --version
.:YcmDebugInfo
.the
:YcmToggleLogs
command.version) I am using.
my issue, including what I expected to happen and what actually happened.
of
install.py
(orcmake
/make
/ninja
) including its invocationthat any help I receive is a selfless, heartfelt gift of their free time. I
know I am not entitled to anything and will be polite and courteous.
actually perform all of these steps.
Issue Details
This is not a bug report, but a feature request specific for C++.
Absolute majority of my functions are not overloaded (and I believe this is the case for most C++ projects). Some even are declared inside
extern "C" {}
, which means they can't be overloaded. The problem is when calling a function with wrong parameters, YCM displays the errorno matching function for call to 'func_name'
, and highlights the function name, instead of displaying what is wrong with the arguments and highlighting the arguments.My suggestion is: when there is only one possible candidate (or even maybe only one candidate with that number of parameters), YCM should display the reason why that particular function candidate failed, highlighting the offending arguments. Most of the times it would be far more useful than the
no matching function for call ...
error.The text was updated successfully, but these errors were encountered: