[commit: ghc] master: Fix unsafe usage of `is_iloc` selector in Ord instance for ImportSpec (6e4188a)
git at git.haskell.org
git at git.haskell.org
Tue Dec 6 22:14:54 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/6e4188abf36d3b489ff7c9586ca49fe922f2beb7/ghc
>---------------------------------------------------------------
commit 6e4188abf36d3b489ff7c9586ca49fe922f2beb7
Author: Matthew Pickering <matthewtpickering at gmail.com>
Date: Tue Dec 6 18:09:55 2016 +0000
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
>---------------------------------------------------------------
6e4188abf36d3b489ff7c9586ca49fe922f2beb7
compiler/basicTypes/RdrName.hs | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/compiler/basicTypes/RdrName.hs b/compiler/basicTypes/RdrName.hs
index d60522f..c4e3228 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
More information about the ghc-commits
mailing list