microsoft / microsoft/vscode-cpptools

Intellisense not recognizing constexpr methods of captured values in lambda

Open
#4,917 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10 18362
  • VS Code Version: 1.41.1
  • C/C++ Extension Version: 0.26.3
  • I have CMake tools installed

To Reproduce

  1. Write
auto array = std::array<int, 4>{};
array = [&array]{ return std::array<int, array.size()>{}; }();
  1. Intellisense will say "Expression must have constant value -- *this cannot be used as constant value"
    (For some reason my Intellisense won't give error messages in English, that error message above is translated from Chinese "表达式必须含有常量值 -- *this 的值不能用作常数")

Expected behavior

This shouldn't be flagged as an error since it's valid:

Screenshots

image

Additional context
Cpp Properties:

{
  "compilerPath": "C:/MyMinGW/i686-9.2.0-static-release-win32-dwarf-rt_v6/mingw32/bin/gcc.exe",
  "cStandard": "c11",
  "cppStandard": "c++17",
  "configurationProvider": "vector-of-bool.cmake-tools",
  "compileCommands": "${workspaceFolder}/build/compile_commands.json"
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported C++17 snippet with the listed compiler and CMake configuration, then compare IntelliSense's diagnostic with the compiler's result. Trace the language-service handling of constexpr expressions involving captured lambda values; done means the valid expression is no longer flagged as an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.