Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/src/Parse/String.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ multiStringBody leadingWhitespace pos end row col initialPos sr sc revChunks =
if word == 0x27 {- ' -}
then
let !pos1 = plusPtr pos 1
in dropLeadingWhiteSpaceThenMultiString 0 leadingWhitespace pos1 end row (col + 1) pos1 sr sc $
in multiStringBody leadingWhitespace pos1 end row (col + 1) pos1 sr sc $
addEscape singleQuote initialPos pos revChunks
else
if word == 0x0A {- \n -}
Expand All @@ -238,10 +238,10 @@ multiStringBody leadingWhitespace pos end row col initialPos sr sc revChunks =
if word == 0x5C {- \ -}
then case eatEscape (plusPtr pos 1) end row col of
EscapeNormal ->
dropLeadingWhiteSpaceThenMultiString 0 leadingWhitespace (plusPtr pos 2) end row (col + 2) initialPos sr sc revChunks
multiStringBody leadingWhitespace (plusPtr pos 2) end row (col + 2) initialPos sr sc revChunks
EscapeUnicode delta code ->
let !newPos = plusPtr pos delta
in dropLeadingWhiteSpaceThenMultiString 0 leadingWhitespace newPos end row (col + fromIntegral delta) newPos sr sc $
in multiStringBody leadingWhitespace newPos end row (col + fromIntegral delta) newPos sr sc $
addEscape (ES.CodePoint code) initialPos pos revChunks
EscapeProblem r c x ->
Err r c (E.StringEscape x)
Expand Down
15 changes: 15 additions & 0 deletions tests/Parse/MultilineStringSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ spec = do
"string with \" in it"
"\"\"\"\nstring with \" in it\"\"\""

it "single quotes don't eat spaces" $ do
parse
"quote followed by spaces: \\' "
"\"\"\"\n quote followed by spaces: \' \"\"\""

it "escapes don't eat spaces" $ do
parse
"quote followed by spaces: \\' "
"\"\"\"\n quote followed by spaces: \\' \"\"\""

it "unicode escapes don't eat spaces" $ do
parse
"quote followed by spaces: \\u0020 "
"\"\"\"\n quote followed by spaces: \\u{0020} \"\"\""

it "first newline, and leading whitespace, is dropped" $ do
parse
"this is\\na test"
Expand Down