microsoft / microsoft/vscode-cpptools
Autocomplete does not work for objects marked const
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and Version: Ubuntu 23.04
- VS Code Version: 1.79.0
- C/C++ Extension Version: 1.16.3
Bug Summary and Steps to Reproduce
Bug Summary:
Normally if you instantiate an object that has some constrains on members and methods, those members and methods will autofill. This does not happen if the object in marked const.
I'm using GCC 13.0.1 x86_64. The following code is a minimal example.
#include <concepts>
struct Types
{
struct Real
{
void reduce() const {}
};
};
template <typename Real>
concept IsReal =
requires (const Real real) {
{
real.reduce()
} -> std::same_as<void>;
};
template <IsReal Real>
struct Foo {
Foo () {
Real real;
real.reduce(); // this will autocomplete
const Real const_real;
const_real.reduce(); // this will NOT autocomplete
}
};
int main()
{
Foo<Types::Real> {};
}
Configuration and Logs
I don't have a c_cpp_properties.json in my .vscode directory. Only a settings.json, and the only field besides file associations is
"C_Cpp.default.compilerPath": "/usr/bin/gcc-13"
### Other Extensions
_No response_
### Additional context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal C++ example in the issue and compare autocomplete for the non-const and const objects in VS Code with the C/C++ extension. Trace the completion behavior for constrained types and confirm that members and methods such as reduce() appear for const objects without regressing the existing non-const case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100