diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2019-04-17 17:56:56 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-22 14:37:30 -0400 |
commit | 1a7a329b983fa03f4115b769ede5c2e148abaad0 (patch) | |
tree | f2c790aaeed11a25d2142e035d5a042ca45000cd /ghc | |
parent | 36e51406eb5c551f6fdc5b2f9e087c1d3a809141 (diff) | |
download | haskell-1a7a329b983fa03f4115b769ede5c2e148abaad0.tar.gz |
Correct off by one error in ghci +c
Fixes #16569
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 8 | ||||
-rw-r--r-- | ghc/GHCi/UI/Info.hs | 3 |
2 files changed, 9 insertions, 2 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 21ef7969ba..383b7fe302 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -2146,7 +2146,9 @@ parseSpanArg s = do let fs = mkFastString fp span' = mkRealSrcSpan (mkRealSrcLoc fs sl sc) - (mkRealSrcLoc fs el ec) + -- End column of RealSrcSpan is the column + -- after the end of the span. + (mkRealSrcLoc fs el (ec + 1)) return (span',trailer) where @@ -2192,7 +2194,9 @@ showRealSrcSpan spn = concat [ fp, ":(", show sl, ",", show sc sl = srcSpanStartLine spn sc = srcSpanStartCol spn el = srcSpanEndLine spn - ec = srcSpanEndCol spn + -- The end column is the column after the end of the span see the + -- RealSrcSpan module + ec = let ec' = srcSpanEndCol spn in if ec' == 0 then 0 else ec' - 1 ----------------------------------------------------------------------------- -- | @:kind@ command diff --git a/ghc/GHCi/UI/Info.hs b/ghc/GHCi/UI/Info.hs index d42f019e5f..2bf061f3b5 100644 --- a/ghc/GHCi/UI/Info.hs +++ b/ghc/GHCi/UI/Info.hs @@ -75,6 +75,9 @@ data SpanInfo = SpanInfo -- locality, definition location, etc. } +instance Outputable SpanInfo where + ppr (SpanInfo s t i) = ppr s <+> ppr t <+> ppr i + -- | Test whether second span is contained in (or equal to) first span. -- This is basically 'containsSpan' for 'SpanInfo' containsSpanInfo :: SpanInfo -> SpanInfo -> Bool |