summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/basicTypes/SrcLoc.hs13
-rw-r--r--compiler/coreSyn/CoreSyn.hs3
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/basicTypes/SrcLoc.hs b/compiler/basicTypes/SrcLoc.hs
index 45d92d0188..af757f5ca7 100644
--- a/compiler/basicTypes/SrcLoc.hs
+++ b/compiler/basicTypes/SrcLoc.hs
@@ -344,11 +344,14 @@ isOneLineSpan (UnhelpfulSpan _) = False
-- that it covers at least as much source code. True where spans are equal.
containsSpan :: RealSrcSpan -> RealSrcSpan -> Bool
containsSpan s1 s2
- = srcSpanFile s1 == srcSpanFile s2
- && (srcSpanStartLine s1, srcSpanStartCol s1)
- <= (srcSpanStartLine s2, srcSpanStartCol s2)
- && (srcSpanEndLine s1, srcSpanEndCol s1)
- >= (srcSpanEndLine s2, srcSpanEndCol s2)
+ = srcSpanEndCol s1 >= srcSpanEndCol s2
+ && srcSpanStartCol s1 <= srcSpanStartCol s2
+ && srcSpanEndLine s1 >= srcSpanEndLine s2
+ && srcSpanStartLine s1 <= srcSpanStartLine s2
+ && srcSpanFile s1 == srcSpanFile s2
+ -- ordered roughly by the likelihood of failing:
+ -- * we're more likely to be comparing source spans from the same file
+ -- * we're more likely to be comparing source spans on the same line
{-
%************************************************************************
diff --git a/compiler/coreSyn/CoreSyn.hs b/compiler/coreSyn/CoreSyn.hs
index bcf9e6eb4d..4ea913bfa1 100644
--- a/compiler/coreSyn/CoreSyn.hs
+++ b/compiler/coreSyn/CoreSyn.hs
@@ -809,7 +809,8 @@ tickishPlace SourceNote{} = PlaceNonLam
-- making the second tick redundant.
tickishContains :: Eq b => Tickish b -> Tickish b -> Bool
tickishContains (SourceNote sp1 n1) (SourceNote sp2 n2)
- = n1 == n2 && containsSpan sp1 sp2
+ = containsSpan sp1 sp2 && n1 == n2
+ -- compare the String last
tickishContains t1 t2
= t1 == t2