
#13553: GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I'm not exactly sure if this is the fault of `cpphs` or GHC, but I'll report this issue to GHC Trac for now, since (ostensibly) the only thing that has changed in this equation is the GHC version. Take this file: {{{#!hs {-# LANGUAGE CPP #-} module Bug where foo :: Int #if __GLASGOW_HASKELL__ >= 800 foo = 42 #else foo = "wrong type" #endif }}} Now let's compile it using `cpphs-1.20.4` as a preprocessor. With GHC 8.0, everything works out fine: {{{ $ /opt/ghc/8.0.2/bin/ghc Bug.hs -pgmP cpphs -optP --cpp Warning: Can't find file "/opt/ghc/8.0.2/lib/ghc-8.0.2/include/ghcversion.h" in directories Asked for by: Bug.hs at line 1 col 1 [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) }}} But with GHC 8.2.1, things go awry: {{{ $ /opt/ghc/8.2.1/bin/ghc Bug.hs -pgmP cpphs -optP --cpp Warning: Can't find file "/opt/ghc/8.2.1/lib/ghc-8.2.0.20170403/include/ghcversion.h" in directories Asked for by: Bug.hs at line 1 col 1 [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) Bug.hs:8:7: error: • Couldn't match expected type ‘Int’ with actual type ‘[Char]’ • In the expression: "wrong type" In an equation for ‘foo’: foo = "wrong type" | 8 | foo = "wrong type" | ^^^^^^^^^^^^ }}} This bug causes several libraries on Hackage which use `cpphs` as a preprocessor to fail when built with GHC 8.2.1, including `Agda`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13553 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler