import SrcLoc ( SrcSpan, srcSpanStart, Located(..), eqLocated, unLoc,
srcLocSpan, getLoc, combineSrcSpans, srcSpanStartLine, srcSpanEndLine )
import Outputable
+import Util ( sortLe )
import ListSetOps ( removeDups )
import List ( nubBy )
import CmdLineOpts
big_loc = foldr1 combineSrcSpans locs
one_line = srcSpanStartLine big_loc == srcSpanEndLine big_loc
locations | one_line = empty
- | otherwise = ptext SLIT("Bound at:") <+> vcat (map ppr locs)
+ | otherwise = ptext SLIT("Bound at:") <+>
+ vcat (map ppr (sortLe (<=) locs))
\end{code}
import Outputable
import Maybes ( isNothing, catMaybes, mapCatMaybes, seqMaybe )
import SrcLoc ( noSrcLoc, Located(..), mkGeneralSrcSpan,
- unLoc, noLoc, srcLocSpan, SrcSpan )
+ unLoc, noLoc, srcLocSpan, combineSrcSpans, SrcSpan )
import BasicTypes ( DeprecTxt )
import ListSetOps ( removeDups )
import Util ( sortLe, notNull, isSingleton )
[] -> pprPanic "exportClashErr" (ppr name)
addDupDeclErr :: [Name] -> TcRn ()
-addDupDeclErr (n:ns)
- = addErrAt (srcLocSpan (nameSrcLoc n)) $
- vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr n),
- nest 2 (ptext SLIT("other declarations at:")),
- nest 4 (vcat (map ppr sorted_locs))]
+addDupDeclErr names
+ = addErrAt big_loc $
+ vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr name1),
+ ptext SLIT("Declared at:") <+> vcat (map ppr sorted_locs)]
where
- sorted_locs = sortLe occ'ed_before (map nameSrcLoc ns)
- occ'ed_before a b = case compare a b of
- LT -> True
- EQ -> True
- GT -> False
+ locs = map nameSrcLoc names
+ big_loc = foldr1 combineSrcSpans (map srcLocSpan locs)
+ name1 = head names
+ sorted_locs = sortLe (<=) (sortLe (<=) locs)
dupExportWarn occ_name ie1 ie2
= hsep [quotes (ppr occ_name),