microsoft / microsoft/vscode-cpptools

"Go to Definition/Declaration" don't work correctly with the function parameters of a `std::function`

Open
#7,595 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service more votes needed Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Language Service

Describe the bug

  • OS and Version: Arch Linux, kernel: 5.10.39-1-lts
  • VS Code Version: 1.56.2
  • C/C++ Extension Version: v1.4.0-insiders3
  • Other extensions you installed (and if the issue persists after disabling them): I don't have other enabled extensions from the "C++" category

When I perform the "Go To Definition" or "Go to Declaration" action on a parameter of the function signature in a std::function type, VSCode navigates to the definition/declaration of std::function in the standard library instead of the actual type definition/declaration. Strangely enough, these actions work properly with the return type of the signature.

Steps to reproduce

  1. Copy the code sample into a .cpp file.
  2. Right click on the foo inside the parentheses and choose either Go to Definition or Go to Declaration.
  3. Observe that VSCode navigates either to the definition of std::function (if Go to Definition was used) or to its declaration.

Expected behavior

VSCode should navigate to the definition of foo within the same file.

Code sample and logs

  • Code sample
#include <functional>

struct foo
{
    int bar;
};

using baz = std::function<foo(foo)>;

int main()
{
    return 0;
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
-------- Diagnostics - 5/26/2021, 10:46:45 AM
Version: 1.4.0-insiders3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
No active translation units.

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 52380
Number of files parsed: 6413

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the provided .cpp sample in VS Code with the C/C++ extension; begin with Go to Definition or Go to Declaration on foo inside std::function<foo(foo)>. Done means both actions navigate to foo's definition in the same file rather than to std::function.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.