Skip to content

Commit

Permalink
Preserve escaped " in String literals
Browse files Browse the repository at this point in the history
Co-authored-by: janmasrovira <janmasrovira@gmail.com>
  • Loading branch information
paulcadman and janmasrovira committed Apr 18, 2023
1 parent 96822c0 commit b362672
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/Juvix/Data/CodeAnn.hs
Expand Up @@ -238,12 +238,7 @@ endSemicolon :: Doc Ann -> Doc Ann
endSemicolon x = x <> kwSemicolon

ppStringLit :: Text -> Doc Ann
ppStringLit = annotate AnnLiteralString . doubleQuotes . escaped
where
showChar :: Char -> String
showChar c = showLitChar c ("" :: String)
escaped :: Text -> Doc a
escaped = mconcatMap (pretty . showChar) . unpack
ppStringLit = annotate AnnLiteralString . pretty @Text . show

bracesIndent :: Doc Ann -> Doc Ann
bracesIndent = braces . blockIndent
Expand Down
4 changes: 4 additions & 0 deletions tests/positive/Format.juvix
Expand Up @@ -46,6 +46,10 @@ t3 :=
, "k"
, "1234";

-- escaping in String literals
e1 : String;
e1 := "\"\n";

infixl 7 +l7;
axiom +l7 : String → String → String;

Expand Down

0 comments on commit b362672

Please sign in to comment.