Compiler ignores Typeable constraint
Compiler allows passing types with no
Typeable instance to functions declared with
Steps to reproduce
The following compiles (no pragmas needed)
import Data.Typeable brokenGhc :: Typeable a => a -> a brokenGhc = id tst = brokenGhc (Foo "bar") brokenGhc2 :: (Typeable a) => a -> String brokenGhc2 = show . typeOf tst2 = brokenGhc2 (Foo "Bar") -- ghci> tst2 -- "Foo" data Foo = Foo String
Possibly related to #10770?
tst2 should not compile. Note
Foo has no instances!
- GHC version used: Tested with ghc-8.6.5/lts-14.0, ghc-8.2.2/lts-12.22
Operating System: Ubuntu 18.04 and Ubuntu 18.10