vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

IntelliSense: mismatching types on auto vs actual type

Open H-G-Hristov opened this issue 2 years ago • 9 comments

Type: Bug

auto val = ILaunchdPlist::KeepAlive::SubkeyType{};

Extension version: 1.12.4 VS Code version: Code 1.71.0 (Universal) (784b0177c56c607789f9638da7b6bf3230d47a8c, 2022-09-01T07:25:38.437Z) OS version: Darwin arm64 21.6.0 Modes: Sandboxed: No

System Info
Item Value
CPUs Apple M1 Pro (8 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 1, 1, 1
Memory (System) 16.00GB (0.79GB free)
Process Argv --crash-reporter-id a7eaff19-94ae-4653-b917-d9aaab19da5d
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30557515
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
pylanb8912:30545647
vsclangdc:30486549
c4g48928:30535728
hb751961:30553087
dsvsc012cf:30540253
azure-dev_surveyone:30548225
i497e931:30553904

H-G-Hristov avatar Sep 04 '22 06:09 H-G-Hristov

Screenshot 2022-09-04 at 9 37 07 Screenshot 2022-09-04 at 9 37 01

Actual type is something like:


namespace utilities {
class LaunchdPlist
{
public:
    struct KeepAlive
    {
        using SubkeyType = ::boost::variant2::variant<
            KeepAlive::SubkeyValueType::AfterInitialDemand,
            KeepAlive::SubkeyValueType::Crashed,
            KeepAlive::SubkeyValueType::NetworkState,
            KeepAlive::SubkeyValueType::OtherJobEnabled,
            KeepAlive::SubkeyValueType::PathState,
            KeepAlive::SubkeyValueType::SuccessfulExit>;
    };
};
}

Instead it's picking up https://github.com/TartanLlama/expected for auto.

H-G-Hristov avatar Sep 04 '22 06:09 H-G-Hristov

@H-G-Hristov This could be due to some IntelliSense configuration error. Could you provide the followings log to help determine the cause of the issue?

  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
  • Logs from the language server (see https://code.visualstudio.com/docs/cpp/enable-logging-cpp#_enable-logging-for-the-language-server)

michelleangela avatar Sep 06 '22 18:09 michelleangela

Yean, it looks like the TU has some errors in it, which could be causing parsing issues at that spot.

sean-mcmanus avatar Sep 07 '22 00:09 sean-mcmanus

Yean, it looks like the TU has some errors in it, which could be causing parsing issues at that spot.

@sean-mcmanus I don't understand what do you mean. The project builds OK.

I'll try to provide the requested logs. Here are more screenshots as an evidence: Screenshot 2022-09-20 at 8 25 04 Screenshot 2022-09-20 at 8 25 59

The extension picks up entirely unrelated types and variables, e.g I have a local variable key but the extension claims is it key from some boost library.

H-G-Hristov avatar Sep 20 '22 06:09 H-G-Hristov

I mean the TU has IntelliSense errors reporting, i.e. our IntelliSense parser is failing to build something, which could be the root cause of the incorrect type.

sean-mcmanus avatar Sep 20 '22 07:09 sean-mcmanus

Is there any chance that this issue is related to: https://github.com/microsoft/vscode-cpptools/issues/9894 After I set the target architecture to x86_64 on Apple M1 host and I restarted VSCode. Everything seems OK for now:

Screenshot 2022-09-20 at 12 30 08

vs

Screenshot 2022-09-20 at 8 25 04

H-G-Hristov avatar Sep 20 '22 10:09 H-G-Hristov

I need to try to reproduce the issue to get some logs.

H-G-Hristov avatar Sep 20 '22 10:09 H-G-Hristov

Yeah, if your repro is in the same scenario as https://github.com/microsoft/vscode-cpptools/issues/9894 that is likely the root cause, but we won't know until we release the fix.

sean-mcmanus avatar Sep 20 '22 17:09 sean-mcmanus

Thank you! I'll wait and I'll update the issue after the fix is released.

H-G-Hristov avatar Sep 21 '22 14:09 H-G-Hristov

I'm still seeing such issues after updating to 1.13.2 I'll wait for the full IntelliSense fix in 1.13.3 if I understand correctly.

This time the issue is with CoreFoundation types which are defined like: typedef const struct CF_BRIDGED_TYPE(NSDictionary) __CFDictionary * CFDictionaryRef; Which VS likes to display as ::remove_pointer(CFDictionaryRef)::Type (I'll have to take a proper screenshot), which it seems to cause other issues.

H-G-Hristov avatar Oct 07 '22 08:10 H-G-Hristov

After CMake configuration/project was loaded, etc.

image

vs

After fresh restart

Screenshot 2022-10-07 at 11 45 12

H-G-Hristov avatar Oct 07 '22 08:10 H-G-Hristov

I don't know what "full IntelliSense fix" you're referring to. There is no pending fix in 1.13.3 for this issue. We need more repro info to know what is going on. If you run C/C++: Log Diagnostics and compare the results with the CMake configuration loaded and a fresh restart you can see what is different in the logging. I can't tell if it's a CMake configuration info or parsing error. Are you able to provide any sample repro code/project? Sometimes using Go to Definition on the headers where the types are defined can reveal IntelliSense errors in the headers which are causing the parsing problems.

sean-mcmanus avatar Oct 07 '22 12:10 sean-mcmanus

This issue has been closed because it needs more information and has not had recent activity.

github-actions[bot] avatar Dec 07 '22 11:12 github-actions[bot]