C++20: Inner class's member functions with `requires` incorrectly show errors
Type: Bug
The following example incorrectly produces an error highlight in IntelliSense:
template <typename T>
struct Dingus {
static constexpr bool IsValid() { return not std::is_same_v<T,void>;}
struct Noot {
int wump() requires (IsValid()) { return 0; }
};
Noot noot() { return {};}
};
int main() {
Dingus<int> d;
d.noot().wump(); // incorrect error/red highlight here!
}
The error produced is:
no instance of function "Dingus<T>::Noot::wump [with T=int]" matches the argument listC/C++(304)
test.cpp(12, 14): object type is: Dingus<int>::Noot
inline int Dingus<int>::Noot::wump()
However, when this is compiled with clang (Apple clang version 15.0.0 (clang-1500.1.0.2.5)), the program compiles successfully with no errors or warnings.
The compiler path is configured to call the system clang++. The compiler standard is set to c++20 (other c++20 features work correctly). There are no project overrides for the compiler path; and I've seen this in multiple projects.
If more information is needed, or if there are settings I should try changing, please let me know!
Extension version: 1.18.5 VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:32.531Z) OS version: Darwin x64 23.3.0 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | 58, 18, 8 |
| Memory (System) | 32.00GB (0.56GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Hi @trbabb . I believe this has been addressed in 1.19.2, which is available as a prerelease in the VS Code marketplace. With 1.19.2 and a couple of minor corrections to your example, I see no squiggles.
#include <type_traits>
template <typename T>
struct Dingus {
static constexpr bool IsValid() { return not std::is_same_v<T,void>;}
struct Noot {
int wump() requires (IsValid()) { return 0; }
};
Noot noot() { return {};}
};
int main() {
Dingus<int> d;
d.noot().wump();
return 0;
}
This issue has been closed because it needs more information and has not had recent activity.