Bug 271073 - Argument completion stops working after invalid previous arg
Summary: Argument completion stops working after invalid previous arg
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (Clang-based) (show other bugs)
Version: git master
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-16 02:43 UTC by Nicolás Alvarez
Modified: 2021-03-17 01:54 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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".