GHC 8.2.1 preprocesses __GLASGOW_HASKELL__ incorrectly with cpphs
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:
{-# 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
.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |