From 56edf70abe6a94685f7398a90ee73dd41dfabcc0 Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 11 Mar 2004 10:52:55 +0000 Subject: [PATCH 1/1] [project @ 2004-03-11 10:52:55 by simonpj] Fix a long-standing bug; the type checker should recover from a failure in the default method of a class declaration, else the default method doesn't get added to the type envt, and we get an opaque tcLookupGlobal: `FunnyError.$dmb' is not in scope message. --- ghc/compiler/typecheck/TcClassDcl.lhs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/typecheck/TcClassDcl.lhs b/ghc/compiler/typecheck/TcClassDcl.lhs index 9ae343b..ee506bc 100644 --- a/ghc/compiler/typecheck/TcClassDcl.lhs +++ b/ghc/compiler/typecheck/TcClassDcl.lhs @@ -336,7 +336,13 @@ tcMethodBind tcMethodBind xtve inst_tyvars inst_theta avail_insts prags (sel_id, meth_id, meth_bind) - = -- Check the bindings; first adding inst_tyvars to the envt + = recoverM (returnM emptyBag) $ + -- If anything fails, recover returning no bindings. + -- This is particularly useful when checking the default-method binding of + -- a class decl. If we don't recover, we don't add the default method to + -- the type enviroment, and we get a tcLookup failure on $dmeth later. + + -- Check the bindings; first adding inst_tyvars to the envt -- so that we don't quantify over them in nested places mkTcSig meth_id `thenM` \ meth_sig -> -- 1.7.10.4