From 38a5d31b08a1c67acdb5a8af73ed0e6d0e42ad6e Mon Sep 17 00:00:00 2001 From: John Date: Fri, 26 Jul 2024 05:51:20 -0500 Subject: [PATCH] cl-ast: Escape string and char literals when pretty-printing --- compiler/cl-ast/src/ast_impl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/cl-ast/src/ast_impl.rs b/compiler/cl-ast/src/ast_impl.rs index 35d83ad..1e25497 100644 --- a/compiler/cl-ast/src/ast_impl.rs +++ b/compiler/cl-ast/src/ast_impl.rs @@ -48,9 +48,9 @@ mod display { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { 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::String(v) => write!(f, "\"{v}\""), + Literal::String(v) => write!(f, "\"{}\"", v.escape_debug()), } } }