summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-02-09 13:57:38 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2022-02-11 10:03:29 +0000
commite9213f63f3d706aefbea77c9480337565235ca3d (patch)
tree35f249326c66a94f815d02085ca444535b1b8dcd
parent775247dfed9fb3962847aa80fdecb86955108c24 (diff)
downloadhaskell-e9213f63f3d706aefbea77c9480337565235ca3d.tar.gz
Use SrcSpan from the binder as initial source estimate
There are some situations where we end up with no source notes in useful positions in an expression. In this case we currently fail to provide any source information about where an expression came from. This patch improves the initial estimate by using the position from the top-binder as the guess for the location of the whole inner expression. It provides quite a course estimate but it's better than nothing. Ticket #20847 (cherry picked from commit a98e55e767764cb810833492b898d1e75f93fd77)
-rw-r--r--compiler/GHC/Stg/Debug.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/GHC/Stg/Debug.hs b/compiler/GHC/Stg/Debug.hs
index 46206d786e..30481baebf 100644
--- a/compiler/GHC/Stg/Debug.hs
+++ b/compiler/GHC/Stg/Debug.hs
@@ -62,7 +62,14 @@ collectStgBind (StgRec pairs) = do
collectStgRhs :: Id -> StgRhs -> M StgRhs
collectStgRhs bndr (StgRhsClosure ext cc us bs e)= do
- e' <- collectExpr e
+ let
+ name = idName bndr
+ -- If the name has a span, use that initially as the source position in-case
+ -- we don't get anything better.
+ with_span = case nameSrcSpan name of
+ RealSrcSpan pos _ -> withSpan (pos, occNameString (getOccName name))
+ _ -> id
+ e' <- with_span $ collectExpr e
recordInfo bndr e'
return $ StgRhsClosure ext cc us bs e'
collectStgRhs _bndr (StgRhsCon cc dc _mn ticks args) = do