C++ : Trailing return types in function declaration result in illegal language match #3673
Open
Description
Describe the issue/behavior that seems buggy
hljs.highlightAuto
does not work on the following example, while hljs.highlightElement
does.
Sample Code or Instructions to Reproduce
hljs.highlightAuto("auto main() -> int {\n auto i = 42; // test\n return i;\n}", [ 'cpp' ])
// result :
{
"language": "cpp",
"value": "auto main() -> int {\n auto i = 42; // test\n return i;\n}",
"illegal": true,
"relevance": 0,
"_illegalBy": {
"message": "Illegal lexeme \"-\" for mode \"function\"",
"index": 11,
"context": "auto main() -> int {\n auto i = 42; // test\n return i;\n}",
"mode": {},
"resultSoFar": ""
},
...
}
This issue seems to be related to the arrow ->
(feature name : trailing return type
), which is legal in post-modern C++.
See the documentation of function declaration, section (2)
(C++11), here on cppreference :
Expected behavior
- Consistency between
highlightAuto
andhighlightElement
behaviors - Proper modern and post-modern C++ synthaxes match & detection