Skip to content

Syntax highlighting breaks in lambda with vector<int> dp(1 << 2) #697

Description

@2445928989

Checklist

  • This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"

If Disabling that^ makes the problem go away, then follow this to make an issue on the C++ extension:
https://github.com/microsoft/vscode-cpptools/issues/new/choose

The code with a problem is:

#include <bits/stdc++.h>
using namespace std;

int main() {
    auto f = [&]() {
        vector<int> dp(1 << 2);
        for (int i = 0; i < 3; ++i) {
            if (i)
                return;
        }
    };
}

It looks like:

Keywords (for/if/return) inside the lambda lose highlighting after the vector dp(1 << 2); line.

Image

It should look like:

Keywords inside the lambda should remain highlighted normally.

Image

Workarounds:

Wrap the expression in parentheses: vector dp((1 << 2));
vector dp(static_cast<size_t>(1ULL << 2));
Precompute the size and pass a variable

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions