Open
Description
Environment
- OS and Version: Windows 10
- VS Code Version: 1.91.1
- C/C++ Extension Version: 1.21.6
- If using SSH remote, specify OS of remote machine:
Bug Summary and Steps to Reproduce
Bug Summary:
When using a lambda with a return value inside of a for loop, cpptools will not allow for extracting to function refactor. The extract to function button is grayed out in the context menu with no reason as to why. When the keyboard shortcut is used (ctrl-shift-r & ctrl-e), the reason given for not being able to extract is because the for loop has control paths that exit without the return value.
Minimal reproducible example:
std::vector<int> testFunction(int a, int b, int size) {
std::vector<int> vec;
auto testAdd = [&]() {
return a+b;
};
for(int i = 0; i < size; i++) {
vec.push_back(a+b);
}
}
Steps to reproduce:
- Select the lambda and the for loop.
- Press the key combination for extract to function
- Receive a tooltip mentioning the above error
Expected behavior:
Extract to function is successful and prompts with function name.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status