#8869 closed bug (invalid)

External preprocessor not used after TH name quote

Reported by: myrix Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.4.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Other Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

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

Change History (1)

comment:1 Changed 14 months ago by simonpj

  • Resolution set to invalid
  • Status changed from new to closed

I suspect that cpp treats the 'id as opening a quotation, and doesn't interpret the FILE inside that quote. So this isn't a bug in GHC, more just that cpp isn't doing what you want.

Reopen if you think it's a bug in GHC

Simon

Note: See TracTickets for help on using tickets.