Skip to content

ghc/ghc-6.12.1 interacts strangely with quoted command line parameters

pkgver.hs:

{-# LANGUAGE CPP #-}
main = print PACKAGE_VERSION

PACKAGE_VERSION is expected to be a quoted string.

c:\Sources>ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1

c:\Sources>ghc --make -DPACKAGE_VERSION=\"2.4.1\" pkgver.hs -fforce-recomp
[1 of 1] Compiling Main             ( pkgver.hs, pkgver.o )
Linking pkgver.exe ...

c:\Sources>ghc-6.10.4.exe --make -DPACKAGE_VERSION=\"2.4.1\" pkgver.hs -fforce-recomp
[1 of 1] Compiling Main             ( pkgver.hs, pkgver.o )

pkgver.hs:2:7:
    Couldn't match expected type `b -> c' against inferred type `IO ()'
    In the first argument of `(.)', namely `print 2.4'
    In the expression: print 2.4 . 1
    In the definition of `main': main = print 2.4 . 1

c:\Sources>ghc-6.12.1.exe --make -DPACKAGE_VERSION=\"2.4.1\" pkgver.hs -fforce-recomp
[1 of 1] Compiling Main             ( pkgver.hs, pkgver.o )

pkgver.hs:2:7:
    Couldn't match expected type `b -> c' against inferred type `IO ()'
    In the first argument of `(.)', namely `print 2.4'
    In the expression: print 2.4 . 1
    In the definition of `main': main = print 2.4 . 1

Issue seen in the wild thanks to cabal -w flag. Building darcs with "cabal install darcs-2.4 -w ghc-6.10.4.exe" fails.

Affected 6.10.4 and 6.12.1. More info here: http://bugs.darcs.net/issue1824

Edited by Ian Lynagh -
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information