|
GHC type-checker bug: msg#00065lang.haskell.glasgow.bugs
Hello, The following program: > f :: (forall a. Eq a => [a]) -> Bool > f xs@(x:_) = x > > main = main Causes ghc to report the following: ghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1): cgPanic zddEq {- v a9y -} static binds for: local binds for: Main.main {- v r2X -} SRT labelghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1): initC: srt Please report it as a compiler bug to glasgow-haskell-bugs@xxxxxxxxxxx, or http://sourceforge.net/projects/ghc/. I was surprised that GHC allows pattern matching on things that are of a qualified type, as I think of such things as functions, and if something is Nil or Cons could depend on the type at which it is used (i.e. the dictionary argument). From my experiments it seems that GHC decides what dictionary to pass based on the types of the subpatterns (and reports an ambiguity if this type cannot be determined). Is that the intended meaning? There seem to be some other problems with this feature too, for example if I change the definition for 'f' to: > f [x] = x I get the following error: test1.hs:5: Couldn't match `forall a. (Eq a) => [a]' against `[t]' Expected type: forall a. (Eq a) => [a] Inferred type: [t] When checking the pattern: [x] In the definition of `f': f [x] = x However if I rewrite this to what I thought was equivalent: > f (x:[]) = x ghc accepts the program without a complaint. I realize that hardly anyone writes such programs, I only thought of them because I was wondering if they make sense in the context of my own type checker. -iavor
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | ghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1), Dominic Steinitz |
|---|---|
| Next by Date: | RE: ghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1), Simon Marlow |
| Previous by Thread: | ghc-6.2.1: panic! (the `impossible' happened, GHC version 6.2.1), Dominic Steinitz |
| Next by Thread: | RE: GHC type-checker bug, Simon Peyton-Jones |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |