microsoft / microsoft/vscode-cpptools

Function type instance: Go to definition of function type goes to return type

Aperta
#13,433 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Language Service Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and Version: Linux x64 6.13.8-arch1-1
  • VS Code Version: 1.98.2
  • C/C++ Extension Version: 1.24.3
  • If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce

Bug Summary:
With this minimal example of defining a function type, declaring an instance of this type, and finally defining this function, one of the examples fails to go to definition (F12) or show it upon hover:

using Foo = void;
using RetFoo = Foo();
RetFoo retFoo; // hover wrong: using Foo = void
Foo retFoo() {}

RetFoo retFooUndefined; // hover correct: using RetFoo = Foo ()

using RetVoid = void();
RetVoid retVoid; // hover correct: using RetVoid = void ()
void retVoid() {}

Instead of showing the definition of the (function) type, it shows the return type of the function.

It only happens:

  • when the function definition has been added.
  • If the return type is not a fundamental such as void or int

Steps to reproduce:

  1. Open the code above in the editor
  2. Go to definition of RetFoo in the declaration RetFoo retFoo;
Configuration and Logs
-------- Diagnostics - 3/27/2025, 8:00:29 PM
Version: 1.24.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [],
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "linux-clang-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPath": "/usr/bin/g++",
    "compilerPathIsExplicit": true,
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.default.compilerPath": "/usr/bin/g++",
    "C_Cpp.codeAnalysis.clangTidy.enabled": true,
    "C_Cpp.codeAnalysis.clangTidy.checks.enabled": [
        "cppcoreguidelines-*",
        "performance-*",
        "modernize-*"
    ],
    "C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
        "altera-id-dependent-backward-branch",
        "altera-unroll-loops",
        "android-*",
        "bugprone-easily-swappable-parameters",
        "bugprone-implicit-widening-of-multiplication-result",
        "cert-dcl58-cpp",
        "cert-err33-c",
        "cppcoreguidelines-avoid-magic-numbers",
        "cppcoreguidelines-non-private-member-variables-in-classes",
        "cppcoreguidelines-pro-bounds-pointer-arithmetic",
        "cppcoreguidelines-pro-type-reinterpret-cast",
        "cppcoreguidelines-pro-type-vararg",
        "fuchsia-*",
        "google-readability-*",
        "google-runtime-int",
        "hicpp-vararg",
        "llvm-header-guard",
        "llvmlibc-*",
        "misc-include-cleaner",
        "misc-non-private-member-variables-in-classes",
        "performance-unnecessary-value-param",
        "readability-identifier-length",
        "readability-magic-numbers"
    ],
    "C_Cpp.loggingLevel": "Debug",
    "C_Cpp.autoAddFileAssociations": false
}
Additional Tracked Settings:
{
    "editorTabSize": 4,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {},
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.24.3.0
Current database path: /tmp/{8585037B-B0F4-4459-99C4-3FBEE7EA3BC6}/.browse.VC.db
Translation Unit Mappings:
[ /home/per/ftype.hpp - source TU]:
Translation Unit Configurations:
[ /home/per/ftype.hpp ]
    Process ID: 960004
    Memory Usage: 20 MB
    Compiler Path: /usr/bin/g++
    Include paths:
        system include: /usr/include/c++/14.2.1
        system include: /usr/include/c++/14.2.1/x86_64-pc-linux-gnu
        system include: /usr/include/c++/14.2.1/backward
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include
        system include: /usr/local/include
        system include: /usr/lib/gcc/x86_64-pc-linux-gnu/14.2.1/include-fixed
        system include: /usr/include
    Standard Version: c++17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=140201
Total Memory Usage: 20 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 38903
Other Extensions

No response

Additional context

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione minima in ftype.hpp e riproduci F12 e l'hover su RetFoo nella dichiarazione di retFoo usando la configurazione Linux, C++17 e g++ indicata. Traccia la ricerca della definizione per l'alias del tipo funzione e verifica che venga risolta in using RetFoo = Foo() anziché nel tipo restituito, inclusi i casi segnalati in cui la definizione della funzione esiste e il tipo restituito non è fondamentale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.