1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:27:35 +00:00

AK: Make Formatter<StringView> not choke on Mode::Character

Formatter<char> internally uses Formatter<StringView> when in
Mode::Character, but that would only accept Mode::{Default,String} and
ASSERT_NOT_REACHED() otherwise, causing String::formatted("{:c}", 'a')
to crash
This commit is contained in:
Linus Groh 2020-12-06 16:49:30 +00:00 committed by Andreas Kling
parent 99a6c4ce42
commit 2313e58393

View file

@ -522,7 +522,7 @@ void Formatter<StringView>::format(TypeErasedFormatParams& params, FormatBuilder
ASSERT_NOT_REACHED();
if (m_zero_pad)
ASSERT_NOT_REACHED();
if (m_mode != Mode::Default && m_mode != Mode::String)
if (m_mode != Mode::Default && m_mode != Mode::String && m_mode != Mode::Character)
ASSERT_NOT_REACHED();
if (m_width != value_not_set && m_precision != value_not_set)
ASSERT_NOT_REACHED();