diff --git a/compiler/src/Parse/String.hs b/compiler/src/Parse/String.hs index 84d60150..d05f9817 100644 --- a/compiler/src/Parse/String.hs +++ b/compiler/src/Parse/String.hs @@ -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 -} @@ -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) diff --git a/tests/Parse/MultilineStringSpec.hs b/tests/Parse/MultilineStringSpec.hs index a4daef73..0f1be7fa 100644 --- a/tests/Parse/MultilineStringSpec.hs +++ b/tests/Parse/MultilineStringSpec.hs @@ -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"