microsoft / microsoft/vscode-cpptools

Type of array/vector incorrect in IntelliSense after a typedef and another array/vector

Offen
#7,778 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug Language Service more votes needed Visual Studio
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

Bug type: Language Service

Describe the bug

  • OS and Version: Windows 11 Pro
  • VS Code Version: 1.57.1
  • C/C++ Extension Version: 1.5.0-insiders3
    In some cases the type of the elements of an array/vector is incorrect in IntelliSense after a typedef and another array/vector.

Steps to reproduce

  1. Paste the following code into a cpp file:
#include <vector>

typedef int my_type;
std::vector<my_type> v;

void f(std::vector<int> x) {}
  1. Hover over the f (or x).
  2. The tooltip says x is a std::vector<my_type>.
  3. Notice how under Outline it is displayed as std::vector<float>.

Expected behavior
x should be a std::vector<float>.

A more general way to reproduce this is:

  1. Define a new type: typedef <existing_type> <new_type>;
  2. Define an array/vector of <new_type>.
  3. Define a function/variable that is/has an array/vector of <existing_type>.
  4. IntelliSense will tell it is an array/vector of <new_type>.

Screenshots
image
image

Additional context
Visual Studio 2019 seems to have the same issue.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit der IntelliSense-Verarbeitung des C++ language service für typedefs sowie std::vector- oder Array-Typen und verwende das Reproduktions-Snippet im Issue. Überprüfe den Hover-Tooltip und die Outline-Anzeige für den Funktionsparameter und betrachte den Bug als behoben, wenn beide den korrekten Elementtyp melden, ohne durch das vorangestellte typedef und den vorangestellten vector beeinflusst zu werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.