GHC loops on compiling with optimizations
When compiling the snippet below with optimizations enabled (i.e. ghc -O test.hs
), GHC does not seem to terminate. This happens with at least 7.0.3 and 7.0.4. Without optimizations, it builds fine.
data A = A Int
class C a where
fromHsk :: C a => a -> Int
instance C Int where
fromHsk = fromHsk
instance C A where
fromHsk (A s) = fromHsk s
main = undefined
When building this example with GHC 6.12.4, it fails with a complaint about the bogus type constraints in the declaration of fromHsk:
test.hs:3:0:
All of the type variables in the constraint `C a'
are already in scope (at least one must be universally quantified here)
(Use -XFlexibleContexts to lift this restriction)
When checking the class method: fromHsk :: (C a) => a -> Int
In the class declaration for `C'
After removing these unneeded constraint (i.e. changing the declaration of fromHsk
to fromHsk :: a -> Int
, the snippet above builds even with GHC 7.0.4 and optimizations.
Trac metadata
Trac field | Value |
---|---|
Version | 7.0.4 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |