Skip to content

Erroneous program emits no errors

Consider this (which arose in #14323 (closed)):

class (a~b) => C a b

foo :: C a b => a -> b
foo x = x

hm3 :: C (f b) b => b -> f b
hm3 x = foo x

With GHC 8.2 it compiles without error, but it definitely has a type error; try -ddump-simpl:

hm3 :: forall (f :: * -> *) b. C (f b) b => b -> f b
[GblId, Arity=2, Str=<L,U><L,U>x]
hm3
  = \ (@ (f_a126 :: * -> *))
      (@ b_a127)
      ($dC_a129 :: C (f_a126 b_a127) b_a127)
      _ [Occ=Dead] ->
      case GHC.Types.HEq_sc
             @ *
             @ *
             @ (f_a126 b_a127)
             @ b_a127
             ($dC_a129
              `cast` ((T14323.N:C[0] ; Data.Type.Equality.N:~[0]
                                           <*>_N) <f_a126 b_a127>_N <b_a127>_N
                      :: (C (f_a126 b_a127) b_a127 :: Constraint)
                         ~R# ((f_a126 b_a127 :: *) ~~ (b_a127 :: *) :: Constraint)))
      of cobox_a12p
      { __DEFAULT ->
      case Control.Exception.Base.typeError
             @ 'GHC.Types.LiftedRep
             @ (C b_a127 (f_a126 b_a127))
             "T14323.hs:28:9: error:\n\
             \    \\226\\128\\162 Could not deduce (C b (f b)) arising from a use of \\226\\128\\152foo\\226\\128\\153\n\
             \      from the context: C (f b) b\n\
             \        bound by the type signature for:\n\
             \                   hm3 :: forall (f :: * -> *) b. C (f b) b => b -> f b\n\
             \        at T14323.hs:27:1-28\n\
             \    \\226\\128\\162 In the expression: foo x\n\
             \      In an equation for \\226\\128\\152hm3\\226\\128\\153: hm3 x = foo x\n\
             \(deferred type error)"#
      of wild_00 {
      }
      }

Reason: bug in the error suppression logic in TcErrors

Trac metadata
Trac field Value
Version 8.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