Compiler ignores Typeable constraint
Summary
Compiler allows passing types with no Typeable instance to functions declared with Typeable constraint.
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?
Expected behavior
tst and tst2 should not compile. Note Foo has no instances!
Environment
- GHC version used: Tested with ghc-8.6.5/lts-14.0, ghc-8.2.2/lts-12.22
Optional:
-
Operating System: Ubuntu 18.04 and Ubuntu 18.10
-
System Architecture:
Suggested Labels:
Edited by Robert Peszek