Bad eta expand

Donald Bruce Stewart dons at cse.unsw.edu.au
Fri Aug 8 01:23:27 EDT 2003


Hey all.

>From a larger program I pruned down the following code which
generates this error message:


$ ghc-6.0 -O -package unix bug.hs
Bad eta expand
    __coerce
      (# GHCziPrim.Statezh {- tc 32q -} GHCziPrim.RealWorld {- tc 31E -},
         a {- tv a29a -} #)
    zdwzdj {- v s2dV -}
    (# GHCziPrim.Statezh {- tc 32q -} GHCziPrim.RealWorld {- tc 31E -},
       a {- tv a29a -} #)


I managed to get the same error on Linux and OpenBSD, with 6.0 and 6.0.1
The error disappears if you use -Onot, understandably.

The program compiles, nonetheless, but in my original program it
would then exhibit strange behaviour: it wouldn't execute
calls to system(). This smaller program seems to run fine,
though.

Here's the smallest program that would reproduce the error:

------------------------------------------------------------------------

-- compile with:
--  ghc -O -package unix bug.hs

import System.Exit          (ExitCode(..),exitWith)
import System.Posix         (getEnv)
import System.Console.GetOpt

main = do 
    a <- return ["f"]
    b <- p a

    () <- case b of 
        ""  -> f
        _   -> g b

    exitWith ExitSuccess

f = getEnv "" >> return ()

g a = return $ if a == "" then () else () 

p a = case (getOpt Permute [] a) of      
        (_,n,_) -> return $ if length n == 1 then head n else ""

------------------------------------------------------------------------

Cheers,
    Don



More information about the Glasgow-haskell-bugs mailing list