[GHC] #12391: LANGUAGE CPP messes up parsing when backslash like \\ is at end of line (eol)

GHC ghc-devs at haskell.org
Thu Jul 14 09:05:10 UTC 2016


#12391: LANGUAGE CPP messes up parsing when backslash like \\ is at end of line
(eol)
-------------------------------------+-------------------------------------
           Reporter:  andreas.abel   |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
  (Parser)                           |
           Keywords:  CPP            |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 {{{#!hs
 {-# LANGUAGE CPP #-}

 import Data.List as List

 main = putStrLn $
   "not nice" List.\\
     "hot mice"
 }}}
 fails with recent ghc (I tried >= 7.8).
 {{{
     Not in scope: ‘List.\’
 }}}
 This problem occurred in a larger context, see
 https://travis-ci.org/agda/agda/jobs/144514733

 It can be traced back to the use of cpp as preprocessor:
 {{{
 $ cpp BackslashAtEOL.hs
 # 1 "BackslashAtEOL.hs"
 # 1 "<built-in>" 1
 # 1 "<built-in>" 3
 # 328 "<built-in>" 3
 # 1 "<command line>" 1
 # 1 "<built-in>" 2
 # 1 "BackslashAtEOL.hs" 2
 {-# LANGUAGE CPP #-}

 import Data.List as List

 main = putStrLn $
   "not nice" List.\     "hot mice"
 }}}
 In contrast, cpphs would work correctly here:
 {{{
 $ cpphs BackslashAtEOL.hs
 #line 1 "BackslashAtEOL.hs"
 {-# LANGUAGE CPP #-}

 import Data.List as List

 main = putStrLn $
   "not nice" List.\\
     "hot mice"
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12391>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list