Find All References on a variable template returns nothing

未关闭
#14,631 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
cpp, typescript

调研方向

从 P1-var-template-zeroValue.zip 开始,检查 src/extras.h:22 以及 main.cpp:150-151 中的使用位置。跟踪针对 variable-template 符号的 textDocument/references 处理,并将报告的结果与预期的三个引用进行比较。当 Find All References 返回声明和两个实例化使用位置时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

bug Feature: Find All References Language Service
Environment

cpptools — Find All References on the variable template ex::zeroValue returns nothing

Field Value
Symbol (spec id) var-template-zeroValue
Declaration template <class T> constexpr T zeroValue = T(0); (variable template)
Query position src/extras.h:22:13 (cursor on zeroValue)
Affected LSP request textDocument/references
Repro archive P1-var-template-zeroValue.zip (this folder)

Summary

Find All References on the variable template ex::zeroValue returns no references in VS Code with the C/C++ extension (cpptools), missing both instantiation uses. The symbol appears unused even though it is instantiated twice.

Environment

  • Editor: Visual Studio Code 1.33.5
  • Extension: C/C++ (ms-vscode.cpptools), default IntelliSense engine
  • Language standard: C++20 (freestanding fixture; no STL/toolchain required)

Steps to reproduce

  1. Extract P1-var-template-zeroValue.zip and open the cpp-project folder in VS Code (C/C++ extension enabled).
  2. Optionally configure with CMake Tools (preset cdb); the fixture also parses under default C++20 IntelliSense.
  3. Open src/extras.h, place the cursor on zeroValue in constexpr T zeroValue = T(0); (line 22, col 13).
  4. Invoke Find All References (Shift+Alt+F12).

Expected vs actual

Source Result count
Expected 3
VS Code / cpptools 0 (no references)

Expected (3): the template declaration (extras.h:22) and its two instantiation uses in main()ex::zeroValue<int> (main.cpp:150) and ex::zeroValue<double> (main.cpp:151).

Actual (0): "Find All References" reports no results (the instantiation uses are not found).

Why it matters

A false "no references" on a live symbol is high risk: an automated agent (or a developer) can conclude the variable template is dead and delete it, breaking the two instantiations.

Bug Summary and Steps to Reproduce

P1-var-template-zeroValue.zip

主要语言
TypeScript
星标
6.2k
派生
1.7k
平均合并
14 小时 46 分钟
30 天内合并 PR
61

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-cpptools 的其他 Issue

查看 microsoft/vscode-cpptools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。