Skip to content

Misplaced SPECIALIZE instance pragma silently ignored

The user's guide for GHC 7.2.2 says that a SPECIALIZE instance pragma must occur inside the where part of the instance declaration (http://www.haskell.org/ghc/docs/7.2.2/html/users_guide/pragmas.html#specialize-instance-pragma), but it is not checked by GHC 7.2.2 (GHC 7.4.1 RC1 (7.4.0.20111219) correctly yields an error in this situation).

For example, the following code is accepted

data Foo a = MkFoo a

{-# SPECIALIZE instance Eq (Foo Int) #-}
instance (Eq a) => Eq (Foo a) where
  MkFoo a1 == MkFoo a2 = a1 == a2

I don't understand the core code, but using the flags -ddump-simpl-stats and -dppr-debug I see a different output with/without a misplaced SPECIALIZE instance pragma, so I guess the pragma is being silently ignored. Can anyone confirm this please?

Trac metadata
Trac field Value
Version 7.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information