Skip to content

CPP breaks multiline string syntax

Summary

When CPP language extension is enabled, multiline strings don't work (as expected).

Steps to reproduce

{-# LANGUAGE CPP #-}
main = putStrLn "hello \
                \world"
a.hs:2:41: error:
    lexical error in string/character literal at character 'w'
  |
2 | main = putStrLn "hello \
  |                                         ^

(The caret is misplaced due to #14113.)

Bad Workaround

Extra slash at the end of the dangling part:

{-# LANGUAGE CPP #-}
main = putStrLn "hello \\
                \world"

Environment

  • GHC version used: 8.6.4
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information