better-cpp-syntax
better-cpp-syntax copied to clipboard
static_assert will break the highlighting of the expression with template parameters
Checklist
- [x] This problem exists even with the setting
"C_Cpp.enhancedColorization": "Disabled" - [ ] This bug exists for C
- [x] This bug exists for C++
- [ ] This bug exists for Objective-C
- [ ] This bug exists for Objective-C++
The code with a problem is:
// right
(py::detail::all_of<
// char will be cast to either signed char or unsigned char
py::detail::any_of<
std::is_same<py::enum_<ScopedCharEnum>::Scalar, signed char>, // e.g.
std::is_same<py::enum_<ScopedCharEnum>::Scalar, unsigned char>>>::value);
// wrong
static_assert(py::detail::all_of<
// char will be cast to either signed char or unsigned char
py::detail::any_of<
std::is_same<py::enum_<ScopedCharEnum>::Scalar, signed char>, // e.g.
std::is_same<py::enum_<ScopedCharEnum>::Scalar, unsigned char>>>::value);
It looks like:

It should look like:
Like this:

Integrated effect:

and

It looks like it is confusing the comma at column 55 with the start of the static assert message.
Potential solutions:
- have the comma lookahead for a double or single quote (per [dcl.pre]/1 only string literals are allowed in the message)
- doesn't fix
static_assert(static_strlen<size_t, "abcdef">::value == 6);
- move the message check after the evaluation context
- I think this may, in some circumstances, cause a lack of tagging for the message (probably minor)
- remove the message match entirely (could be useful if 2 leads to inconsistent highlighting)
- Attempt to match the entire string literal and lookahead for
EOLor)