[ ghc-Bugs-1200592 ] GHC fails to pass dictionary in a rank-2
situation.
SourceForge.net
noreply at sourceforge.net
Thu May 19 04:27:29 EDT 2005
Bugs item #1200592, was opened at 2005-05-12 12:34
Message generated for change (Comment added) made by simonpj
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1200592&group_id=8032
Category: Compiler
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: GHC fails to pass dictionary in a rank-2 situation.
Initial Comment:
Hello,
The following code leads to a run- or compile-time error.
\begin{code}
{-# OPTIONS -fglasgow-exts #-}
module Main () where
foo :: (forall m. Monad m => m a) -> IO a
foo = id . id
main :: IO ()
main = foo (return ())
\end{code}
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
glasgow-haskell-bugs at haskell.org,
or http://sourceforge.net/projects/ghc/.
$ 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
and
> foo = id
behave correctly.
Tested with ghc-6.2.2, ghc-6.4 and the latest ghc-6.5
snapshot.
-- Thomas Jäger <ThJaeger at gmail.com>
----------------------------------------------------------------------
>Comment By: Simon Peyton Jones (simonpj)
Date: 2005-05-19 08:27
Message:
Logged In: YES
user_id=50165
tcrun035 tests it
----------------------------------------------------------------------
Comment By: Simon Peyton Jones (simonpj)
Date: 2005-05-12 16:52
Message:
Logged In: YES
user_id=50165
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
Simon
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=108032&aid=1200592&group_id=8032
More information about the Glasgow-haskell-bugs
mailing list