[Bug] Wrong syntax highlighting in c++'s attribute specifiers
#3,395 opened on Nov 5, 2022
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Code
[edit]
monaco.editor.create(document.getElementById('container'), {
value: "[[nodiscard(\"is the word using highlighted? Yes it is and alignas too.\")]]\nint test() {\n return 42;\n}",
language: 'cpp'
});
[/edit]
Reproduction Steps
- visit godbolt.org
- Use C++ & x86-64 GCC 12.2
- add this code snippet
[[nodiscard("is the word using highlighted? Yes it is")]]
int test() {
return 42;
}
or the extended
#include <iostream>
[[nodiscard("is the word using highlighted? Yes it is")]]
int test() {
return 42;
std::cout << "but here it is okay to use the word using \n";
}
or just use this link https://godbolt.org/z/4cc31Wf4Y
Actual (Problematic) Behavior
Syntax highlighting is wrong when using specific keywords in string literals in attribute specifiers. Found only the word "using" but properly there are more. [edit]same for alignas[/edit]
The following (key)words don't have the problem:
- volatile
- static
- mutable
- const
- return
- int
- "#include"
just see the color of the word "using"
same for the extended code

the other (key)words:

and for completion here the vscode version
Expected Behavior
Since it is a string literal, it should be the same color as other parts of the text.
Additional Context
When using godbolt, this bug appeared. The issue based on it is to be found at https://github.com/compiler-explorer/compiler-explorer/issues/4239 The suggestion was to create a issue here, since their syntax highlighting is monaco based.
relevant quotes:
RubenRBS Hi! Thanks for the report. While we can probably patch this in our end, we ultimately rely on Microsof's own Monaco editor syntax highlighting for C++. Can you report this issue in https://github.com/microsoft/monaco-editor? If anyone wants to try and fix it, the offending file can be found in https://github.com/microsoft/monaco-editor/blob/main/src/basic-languages/cpp/cpp.ts
mattgodbolt In fairness I think I patched support for this kind of stuff upstream in monaco 馃槉 so it could still be my fault... but yeah, probably an expert there (ie not me) should take a look.