Commit 0e2c5824 authored by simonpj's avatar simonpj

[project @ 2004-09-02 15:18:34 by simonpj]

Make error messages consistent
parent cc8f20ad
......@@ -358,11 +358,11 @@ setOccNameSpace :: NameSpace -> OccName -> OccName
setOccNameSpace sp (OccName _ occ) = OccName sp occ
-- occNameFlavour is used only to generate good error messages
occNameFlavour :: OccName -> String
occNameFlavour (OccName DataName _) = "data constructor"
occNameFlavour (OccName TvName _) = "type variable"
occNameFlavour (OccName TcClsName _) = "type constructor or class"
occNameFlavour (OccName VarName s) = ""
occNameFlavour :: OccName -> SDoc
occNameFlavour (OccName DataName _) = ptext SLIT("data constructor")
occNameFlavour (OccName TvName _) = ptext SLIT("type variable")
occNameFlavour (OccName TcClsName _) = ptext SLIT("type constructor or class")
occNameFlavour (OccName VarName s) = empty
-- briefOccNameFlavour is used in debug-printing of names
briefOccNameFlavour :: OccName -> String
......
......@@ -210,7 +210,7 @@ instance Outputable RdrName where
ppr (Qual mod occ) = ppr mod <> dot <> ppr occ <+> ppr_name_space occ
ppr (Orig mod occ) = ppr mod <> dot <> ppr occ <+> ppr_name_space occ
ppr_name_space occ = ifPprDebug (parens (text (occNameFlavour occ)))
ppr_name_space occ = ifPprDebug (parens (occNameFlavour occ))
instance OutputableBndr RdrName where
pprBndr _ n
......
......@@ -705,7 +705,9 @@ warnUnusedBinds names = mappM_ warnUnusedName (filter reportable names)
warnUnusedName :: (Name, Maybe Provenance) -> RnM ()
warnUnusedName (name, prov)
= addWarnAt loc (sep [msg <> colon, nest 4 (ppr name)])
= addWarnAt loc $
sep [msg <> colon,
nest 2 $ occNameFlavour (nameOccName name) <+> quotes (ppr name)]
-- TODO should be a proper span
where
(loc,msg) = case prov of
......@@ -735,13 +737,9 @@ shadowedNameWarn doc shadow
ptext SLIT("shadows an existing binding")]
$$ doc
unknownNameErr name
unknownNameErr rdr_name
= sep [ptext SLIT("Not in scope:"),
if isVarOcc occ_name then quotes (ppr name)
else text (occNameFlavour occ_name)
<+> quotes (ppr name)]
where
occ_name = rdrNameOcc name
nest 2 $ occNameFlavour (rdrNameOcc rdr_name) <+> quotes (ppr rdr_name)]
unknownInstBndrErr cls op
= quotes (ppr op) <+> ptext SLIT("is not a (visible) method of class") <+> quotes (ppr cls)
......
......@@ -740,7 +740,7 @@ reportDeprecations tcg_env
, Just deprec_txt <- lookupDeprec hpt pit name
= addSrcSpan (is_loc imp_spec) $
addWarn (sep [ptext SLIT("Deprecated use of") <+>
text (occNameFlavour (nameOccName name)) <+>
occNameFlavour (nameOccName name) <+>
quotes (ppr name),
(parens imp_msg),
(ppr deprec_txt) ])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment