summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2016-12-06 18:09:55 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2016-12-06 22:14:22 +0000
commit6e4188abf36d3b489ff7c9586ca49fe922f2beb7 (patch)
treef64ea818eb91bb2953367c426720d843b8b5e6af
parent19ae142364058e258122f4bb68ef4b9aa6e41890 (diff)
downloadhaskell-6e4188abf36d3b489ff7c9586ca49fe922f2beb7.tar.gz
Fix unsafe usage of `is_iloc` selector in Ord instance for ImportSpec
Summary: This fixes tests rn017, T7672 and closed #12930. Both these tests were self referential module imports through hs-boot files. As a result, I am quite suspicious of what the ImpAll constructor is used for. I had a brief hunt around but couldn't immediately see whether it was necessary. Reviewers: austin, bgamari Subscribers: simonpj, thomie, nomeata Differential Revision: https://phabricator.haskell.org/D2793 GHC Trac Issues: #12930
-rw-r--r--compiler/basicTypes/RdrName.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/basicTypes/RdrName.hs b/compiler/basicTypes/RdrName.hs
index d60522f41c..c4e3228274 100644
--- a/compiler/basicTypes/RdrName.hs
+++ b/compiler/basicTypes/RdrName.hs
@@ -1137,7 +1137,12 @@ instance Eq ImpItemSpec where
p1 == p2 = case p1 `compare` p2 of EQ -> True; _ -> False
instance Ord ImpItemSpec where
- compare is1 is2 = is_iloc is1 `compare` is_iloc is2
+ compare is1 is2 =
+ case (is1, is2) of
+ (ImpAll, ImpAll) -> EQ
+ (ImpAll, _) -> GT
+ (_, ImpAll) -> LT
+ (ImpSome _ l1, ImpSome _ l2) -> l1 `compare` l2
bestImport :: [ImportSpec] -> ImportSpec