[GHC] #14132: Report an error for a missing class instance before an error for type family instances of an associated type.

GHC ghc-devs at haskell.org
Fri Aug 18 16:35:50 UTC 2017


#14132: Report an error for a missing class instance before an error for type
family instances of an associated type.
-------------------------------------+-------------------------------------
        Reporter:  duog              |                Owner:  (none)
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Yes, I think it'd be possible to improve this. At the moment we actually
 ''suppress'' the class error because of the type-equality error.  But with
 a little re-ordering in `TcErrors.reportWanteds` we could fix that.  Then
 we'd at least report both.  Suppressing the equality error because it
 involves an associated type would be significantly harder.  But at least
 you'd get both.

 Specifically the code in `TcErrors` is this
 {{{
     report1 = [ ("custom_error", is_user_type_error,True,
 mkUserTypeErrorReporter)
               , given_eq_spec
               , ("insoluble2",    utterly_wrong,    True, mkGroupReporter
 mkEqErr)
               , ("skolem eq1",    very_wrong,       True, mkSkolReporter)
               , ("skolem eq2",    skolem_eq,        True, mkSkolReporter)
               , ("non-tv eq",     non_tv_eq,        True, mkSkolReporter)
               , ("Out of scope",  is_out_of_scope,  True, mkHoleReporter)
               , ("Holes",         is_hole,          False, mkHoleReporter)

                   -- The only remaining equalities are alpha ~ ty,
                   -- where alpha is untouchable; and representational
 equalities
                   -- Prefer homogeneous equalities over hetero, because
 the
                   -- former might be holding up the latter.
                   -- See Note [Equalities with incompatible kinds] in
 TcCanonical
               , ("Homo eqs",      is_homo_equality, True,  mkGroupReporter
 mkEqErr)
               , ("Other eqs",     is_equality,      False, mkGroupReporter
 mkEqErr) ]

     -- report2: we suppress these if there are insolubles elsewhere in the
 tree
     report2 = [ ("Implicit params", is_ip,           False,
 mkGroupReporter mkIPErr)
               , ("Irreds",          is_irred,        False,
 mkGroupReporter mkIrredErr)
               , ("Dicts",           is_dict,         False,
 mkGroupReporter mkDictErr) ]
 }}}
 I think that moving the "non-tv-eq" line from `report1` into `report2`
 would do the job.  (And maybe change that True to False.)

 The "Homo eqs" and "Other eqs" could move too.

 I'm swamped right now, and this would make lots of error messages in
 `validate` change slightly, each of which needs a check and accept.  But
 maybe someone else can have a go?

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14132#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list