Opened 10 years ago

Closed 10 years ago

Last modified 46 years ago

#382 closed bug (Fixed)

GHC fails to pass dictionary in a rank-2 situation.

Reported by: nobody Owned by: nobody
Priority: normal Milestone:
Component: Compiler Version: None
Keywords: Cc:
Operating System: Architecture:
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):



The following code leads to a run- or compile-time error.
{-# OPTIONS -fglasgow-exts #-}
module Main () where

foo :: (forall m. Monad m => m a) -> IO a
foo = id . id

main :: IO ()
main = foo (return ())

GHC translates `foo' effectively to an identity
function, failing to pass a dictionary to the argument.
  foo :: %forall a . (%forall (m::(*->*)) . ZCTMonad m ->
                                            m a)
                     -> IO a =
    \ @ a ->
        zi @ (IO a) @ (IO a)
        @ (IO a) (id @ (IO a))
        (id @ (IO a));

This doesn't typecheck, therefore 

$ ./ghc-6.5.20050510 -O IsolateBug.hs 
ghc-6.5.20050510: panic! (the `impossible' happened,
GHC version 6.5.20050510):
        No match in record selector Var.idInfo

Please report it as a compiler bug to
[email protected],

$ ghc-6.5.20050510 IsolateBug.hs 
$ ./a.out 
zsh: segmentation fault  ./a.out

The bug still occurs when we give the compiler a little
bit more type information
> foo = (id :: IO a -> IO a) . (id :: IO a -> IO a)
, however
> foo = id . id :: IO a -> IO a
> foo = id
behave correctly.

Tested with ghc-6.2.2, ghc-6.4 and the latest ghc-6.5

-- Thomas Jäger <[email protected]>

Change History (2)

comment:1 Changed 10 years ago by simonpj

Logged In: YES 

Oh crumbs!  This turns out to be an omission for ages.
Easily fixed, just an omitted call.

Thanks for the report.  It's fixed in the HEAD, and we'll merge 
into 6.4.1


comment:2 Changed 10 years ago by simonpj

  • Status changed from assigned to closed
Logged In: YES 

tcrun035 tests it
Note: See TracTickets for help on using tickets.