rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.32k stars 731 forks source link

C++ lambda in default template argument is incorrectly highlighted as error #1837

Closed MC-DeltaT closed 2 years ago

MC-DeltaT commented 2 years ago

Name of the lexer C++

Code sample

template<auto F = []{}>
void func();

Demo: http://rouge.jneen.net/v3.29.0/cpp/dGVtcGxhdGU8YXV0byBGID0gW117fT4Kdm9pZCBmdW5jKCk7Cg

Additional context In general, I'd expect that any expression is valid in a template argument default.

MC-DeltaT commented 2 years ago

Actually seems like any braces in a template argument default is incorrectly highlighted as an error.

E.g. with a requires expression:

template<auto F = requires { foo(); }>
void func();

Demo: http://rouge.jneen.net/v3.29.0/cpp/dGVtcGxhdGU8YXV0byBGID0gcmVxdWlyZXMgeyBmb28oKTsgfT4Kdm9pZCBmdW5jKCk7Cg