Bug 271073

Summary: Argument completion stops working after invalid previous arg
Product: [Applications] kdevelop Reporter: Nicolás Alvarez <nalvarez>
Component: Language Support: CPP (Clang-based)Assignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: craftplace.ms
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nicolás Alvarez 2011-04-16 02:43:38 UTC
Code snippet:

struct Foo; struct Bar;

void func(int, Foo*);

void test() {
    int x=1;
    Foo* foo;
    Bar* bar;
    func(
}

In the ‘func’ call, Ctrl-Space correctly offers ‘x’ as best match. After selecting that option and typing a comma, ie. after “func(x, ”, it correctly offers ‘foo’ as best match.

However, if the first argument is invalid, completion for the second argument doesn't work. For example, completion after “func(nonexistingvar, ” shows all local variables in alphabetical order, and no “best matches” section at all.

I understand this might be due to overloading: if there are several overloads of ‘func’, KDevelop may not know the type of the function's second parameter until it knows what overload I'm using, and for that it may need the type of the first argument. But then there should be special handling for the case of ‘func’ having only one overload, like in the above example.
Comment 1 Andrey Cygankov 2016-01-23 23:20:03 UTC
I tried to reproduce the bug in KDevelop5, and it not shows all local variables. 
http://i.imgur.com/y5BDLya.png
Probably it is necessary to close.
Comment 2 Nicolás Alvarez 2016-01-23 23:22:48 UTC
This is probably fixed in KDevelop5, but your screenshot is not really evidence for it. You should write a comma and see what completion you get on the *second* argument. It should offer 'foo' (because the type matches) above other local variables.

I don't currently have KDevelop5 to try it myself.
Comment 3 Andrey Cygankov 2016-01-23 23:53:56 UTC
Sorry, I did not immediately understand.

Yes, the bug is still there.
http://i.imgur.com/8eIIuc9.png
Comment 4 Nicolás Alvarez 2016-01-23 23:58:53 UTC
Oh wow, I really imagined it would work now. Thanks for testing!
Comment 5 Milian Wolff 2016-01-24 12:00:49 UTC
With kdev-clang we'll probably need to fix this in clang itself.
Comment 6 Justin Zobel 2021-03-09 22:48:51 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.
Comment 7 Nicolás Alvarez 2021-03-17 01:54:59 UTC
KDevelop 5.6.2, this so broken that maybe I should file a separate bug. If I complete after "func(" I don't get *any* local variables in the list. My original report was about whether a certain variable was shown in "best matches" or just in the normal list, but now local vars are missing entirely.

If I complete after "func(b" I do get "bar".