#15276 closed bug (fixed)

Bogus type in typechecker error recovery

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


If the typechecker sees

let f = <rhs> in <body>

and there's a type error in <rhs>, GHC recovers from the error, binds f to "a type that should cause no more trouble", and continues with <both> in the hope of finding more type errors.

What is "a type that should cause no more trouble"? Well forall a.a seems like a good candidate.

But, in this commit

commit 6746549772c5cc0ac66c0fce562f297f4d4b80a2
Author: Richard Eisenberg <eir@cis.upenn.edu>
Date:   Fri Dec 11 18:19:53 2015 -0500

    Add kind equalities to GHC.

we made the type look like this: forall r. forall (a :: TYPE r). a

Alas! That type is ill-formed because the kind TYPE r escapes the scope of f.

I discovered this when beefing up typeKind in pursuit of #14939

Change History (2)

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

In 807ab22/ghc:

Fix the bind-recovery type

This patch uses (forall (a::*). a) for the type to
use when recovering from an error in a binding.

Previously (Trac #15276) we had (forall r (a :: TYPE r). a),
which is ill-kinded.

It's quite hard to provoke an error arising from this, because
it only happens in programs that have a type error anyway,
but in a subequent patch I make typeKind fall over if it returns
an ill-scoped kind, and that makes ghci/scripts/T13202 crash
without this fix.

comment:2 Changed 16 months ago by simonpj

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.