cl-ast: Escape string and char literals when pretty-printing

This commit is contained in:
John 2024-07-26 05:51:20 -05:00
parent e43847bbd4
commit 38a5d31b08

View File

@ -48,9 +48,9 @@ mod display {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Literal::Bool(v) => v.fmt(f), Literal::Bool(v) => v.fmt(f),
Literal::Char(v) => write!(f, "'{v}'"), Literal::Char(v) => write!(f, "'{}'", v.escape_debug()),
Literal::Int(v) => v.fmt(f), Literal::Int(v) => v.fmt(f),
Literal::String(v) => write!(f, "\"{v}\""), Literal::String(v) => write!(f, "\"{}\"", v.escape_debug()),
} }
} }
} }