Improve error message when 'forall' is not a keyword
authorsimonpj@microsoft.com <unknown>
Thu, 21 Aug 2008 12:35:02 +0000 (12:35 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 21 Aug 2008 12:35:02 +0000 (12:35 +0000)
compiler/rename/RnEnv.lhs
compiler/rename/RnTypes.lhs

index 6c3567a..03e94bc 100644 (file)
@@ -30,7 +30,7 @@ module RnEnv (
        mapFvRn, mapFvRnCPS,
        warnUnusedMatches, warnUnusedModules, warnUnusedImports, 
        warnUnusedTopBinds, warnUnusedLocalBinds,
-       dataTcOccs, unknownNameErr
+       dataTcOccs, unknownNameErr, perhapsForallMsg
     ) where
 
 #include "HsVersions.h"
@@ -986,10 +986,13 @@ unknownNameErr rdr_name
                          <+> quotes (ppr rdr_name))
         , extra ]
   where
-    extra | rdr_name == forall_tv_RDR 
-         = vcat [ptext (sLit "Perhaps you intended to use -XRankNTypes or similar flag"),
-                 ptext (sLit "to enable explicit-forall syntax: forall <tvs>. <type>?")]
-         | otherwise = empty
+    extra | rdr_name == forall_tv_RDR = perhapsForallMsg
+         | otherwise                 = empty
+
+perhapsForallMsg :: SDoc
+perhapsForallMsg 
+  = vcat [ ptext (sLit "Perhaps you intended to use -XRankNTypes or similar flag")
+        , ptext (sLit "to enable explicit-forall syntax: forall <tvs>. <type>")]
 
 unknownSubordinateErr :: SDoc -> RdrName -> SDoc
 unknownSubordinateErr doc op   -- Doc is "method of class" or 
index 7a0948e..0e047fe 100644 (file)
@@ -538,7 +538,7 @@ opTyErr op ty@(HsOpTy ty1 _ _)
         2 extra
   where
     extra | op == dot_tv_RDR && forall_head ty1
-         = ptext (sLit "Perhaps you intended to use -XRankNTypes or similar flag")
+         = perhapsForallMsg
          | otherwise 
          = ptext (sLit "Use -XTypeOperators to allow operators in types")