[GHC] #8869: External preprocessor not used after TH name quote

GHC ghc-devs at haskell.org
Sun Mar 9 16:55:46 UTC 2014


#8869: External preprocessor not used after TH name quote
----------------------------------+--------------------------
       Reporter:  myrix           |             Owner:
           Type:  bug             |            Status:  new
       Priority:  normal          |         Milestone:
      Component:  Compiler        |           Version:  7.4.1
       Keywords:                  |  Operating System:  Linux
   Architecture:  x86_64 (amd64)  |   Type of failure:  Other
     Difficulty:  Unknown         |         Test Case:
     Blocked By:                  |          Blocking:
Related Tickets:                  |
----------------------------------+--------------------------
 Module
 {{{
 {-# LANGUAGE CPP, TemplateHaskell #-}

 module Main where

 main = do
   putStrLn $ show 'id
   putStrLn __FILE__
 }}}

 fails to compile with external preprocessor:
 {{{
 > ghc -pgmP cpphs -optP --cpp Main.hs
 [1 of 1] Compiling Main             ( Main.hs, Main.o )

 Main.hs:7:12: Not in scope: `__FILE__'
 }}}

 {{{__FILE__}}} is not expanded:
 {{{
 > ghc -E -pgmP cpphs -optP --cpp Main.hs
 > cat Main.hspp
 {-# LINE 1 "Main.hs" #-}
 #line 1 "Main.hs"
 {-# LANGUAGE CPP, TemplateHaskell #-}

 module Main where

 main = do
   putStrLn $ show 'id
   putStrLn __FILE__
 }}}

 Without external preprocessor (just {{{ghc Main.hs}}}) module compiles
 successfully.

 Move name quote after {{{__FILE__}}}, like this:
 {{{
 {-# LANGUAGE CPP, TemplateHaskell #-}

 module Main where

 main = do
   putStrLn __FILE__
   putStrLn $ show 'id
 }}}
 and it work with external preprocessor just fine:
 {{{
 > ghc -pgmP cpphs -optP --cpp Main.hs
 [1 of 1] Compiling Main             ( Main.hs, Main.o )
 Linking Main ...
 > ./Main
 Main.hs
 GHC.Base.id
 }}}

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


More information about the ghc-tickets mailing list