Opened 10 months ago

Closed 9 months ago

Last modified 2 months ago

#14325 closed bug (fixed)

Erroneous program emits no errors

Reported by: simonpj Owned by:
Priority: normal Milestone: 8.2.2
Component: Compiler Version: 8.2.1
Keywords: DeferredErrors Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_fail/T14325
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Consider this (which arose in #14323):

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

Change History (5)

comment:1 Changed 9 months ago by Simon Peyton Jones <simonpj@…>

In c81f66cc/ghc:

Fix over-eager error suppression in TcErrors

See Note [Given insolubles] in TcRnTypes

Fixes Trac #14325.

comment:2 Changed 9 months ago by simonpj

Status: newmerge
Test Case: typecheck/should_fail/T14325

Merge if convenient.

comment:4 Changed 9 months ago by bgamari

Milestone: 8.2.2
Resolution: fixed
Status: mergeclosed

comment:5 Changed 2 months ago by simonpj

Keywords: DeferredErrors added
Note: See TracTickets for help on using tickets.