Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#10230 closed bug (invalid)

multiline literals doesn't work with CPP extension.

Reported by: qnikst Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.10.1
Keywords: cpp Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


If LANGUAGE CPP is enabled then multiline literals stops working. Steps to reproduce.

  1. write a program with multiline literal: cat 1.hs
    test = "mutli\
    main = putStrLn test
  2. it should compile without CPP: ghc 1.hs

[1 of 1] Compiling Main ( 1.hs, 1.o ) Linking 1 ...

  1. compile it with CPP extension

Expected result: program compiles

ghc 1.hs
[1 of 1] Compiling Main             ( 1.hs, 1.o )
Linking 1 ...

Actual result: compilation breaks

ghc -XCPP 1.hs
[1 of 1] Compiling Main             ( 1.hs, 1.o ) [flags changed]

    lexical error in string/character literal at character 'l'

At least ghc-7.8.4 and ghc-7.10 are affected.

Change History (4)

comment:1 Changed 4 years ago by rwbarton

Resolution: invalid
Status: newclosed

If you use -XCPP then you are responsible for ensuring that the output of the C preprocessor is a valid Haskell program. Line continuations (\ at the end of a line) are handled by the C preprocessor (so that you can define multi-line macros). See

comment:2 Changed 4 years ago by hvr

See also Proposal/NativeCpp which may address this issue to some extent

comment:3 Changed 4 years ago by hvr

Keywords: cpp added

comment:4 Changed 2 years ago by chris-martin

Note: See TracTickets for help on using tickets.