Tweak the undecidable-instance-checking logic
authorIan Lynagh <igloo@earth.li>
Mon, 9 Jul 2007 18:22:09 +0000 (18:22 +0000)
committerIan Lynagh <igloo@earth.li>
Mon, 9 Jul 2007 18:22:09 +0000 (18:22 +0000)
Just looking at Opt_GlasgowExts is not sufficient to see if we need
to do an instance undecidability check. Rather than try to enumerate
all the extensions that may require us to do the check we now always
do it.

compiler/typecheck/TcMType.lhs

index e5ccbd0..9746e0c 100644 (file)
@@ -1179,15 +1179,15 @@ instTypeErr pp_ty msg
 \begin{code}
 checkValidInstance :: [TyVar] -> ThetaType -> Class -> [TcType] -> TcM ()
 checkValidInstance tyvars theta clas inst_tys
-  = do { gla_exts <- doptM Opt_GlasgowExts
-       ; undecidable_ok <- doptM Opt_AllowUndecidableInstances
+  = do { undecidable_ok <- doptM Opt_AllowUndecidableInstances
 
        ; checkValidTheta InstThetaCtxt theta
        ; checkAmbiguity tyvars theta (tyVarsOfTypes inst_tys)
 
        -- Check that instance inference will terminate (if we care)
-       -- For Haskell 98, checkValidTheta has already done that
-       ; when (gla_exts && not undecidable_ok) $
+       -- For Haskell 98 this will already have been done by checkValidTheta,
+    -- but as we may be using other extensions we need to check.
+       ; unless undecidable_ok $
          mapM_ addErrTc (checkInstTermination inst_tys theta)
        
        -- The Coverage Condition