summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-09-01 15:54:39 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-09-01 15:54:39 +0100
commitb5b4aae437bba8c93bbe29e3678debceeb3f076e (patch)
tree1b72065fc5e37976c761de93bb723d1e61c81cd1
parentfa71e6c795489ec267e0d048395c2c52bea6a164 (diff)
downloadhaskell-b5b4aae437bba8c93bbe29e3678debceeb3f076e.tar.gz
Wibble to fix of Trac #5439: deal with the error-recovery case
Even if we are recovering from a typecheck error, we should still do the right thing for the "closed" flag. Otherwise we get an assert failure, and potentially different behaviour when the user fixes the original type error.
-rw-r--r--compiler/typecheck/TcBinds.lhs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/typecheck/TcBinds.lhs b/compiler/typecheck/TcBinds.lhs
index 0979e45eb7..3597ebf426 100644
--- a/compiler/typecheck/TcBinds.lhs
+++ b/compiler/typecheck/TcBinds.lhs
@@ -716,12 +716,15 @@ recoveryCode :: [Name] -> SigFun -> TcM (LHsBinds TcId, [Id], TopLevelFlag)
recoveryCode binder_names sig_fn
= do { traceTc "tcBindsWithSigs: error recovery" (ppr binder_names)
; poly_ids <- mapM mk_dummy binder_names
- ; return (emptyBag, poly_ids, TopLevel) }
+ ; return (emptyBag, poly_ids, if all is_closed poly_ids
+ then TopLevel else NotTopLevel) }
where
mk_dummy name
| isJust (sig_fn name) = tcLookupId name -- Had signature; look it up
| otherwise = return (mkLocalId name forall_a_a) -- No signature
+ is_closed poly_id = isEmptyVarSet (tyVarsOfType (idType poly_id))
+
forall_a_a :: TcType
forall_a_a = mkForAllTy openAlphaTyVar (mkTyVarTy openAlphaTyVar)
\end{code}