Skip to content

color formatting issue when parsing a lambda with an explicit return type in C++ #691

@alexr00

Description

@alexr00

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:

void test()
{
  []()->auto{};
}

It looks like:

The semicolon at the end of the lambda expression is colored as if it is a keyword (in my color scheme keywords are blue and the semicolon appears blue as well). It should appear the same color as other punctuation, like commas, operators, etc.
It also causes coloring issues in subsequent lines (keywords are colored as if they are operators and operators are colored as if they are keywords).

Image

The whole auto{}; token is getting the scope storage.type.return-type.lambda.cpp.

It should look like:

Add a whitespace between the return type of the lambda and the body of the lambda.
The following code does not experience this problem:

void test()
{
  []()->auto {}; //note the whitespace between `auto` and `{`
}
Image

Here, the ; is not included in the return-type scope and gets punctuation.terminator.statement.cpp.

Originally posted by @ZamfirYonchev in microsoft/vscode#271277

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