diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2022-03-10 23:23:16 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-05-11 08:23:33 -0400 |
commit | 4a4c77ed8f16f157dd647593de58840b024bbd2d (patch) | |
tree | ca61146523ef92158c599d9693bd9583c08e6146 /compiler/GHC/Parser/PostProcess.hs | |
parent | 8500206ea7084f3914efd3fe7f4336f2893eb4ac (diff) | |
download | haskell-4a4c77ed8f16f157dd647593de58840b024bbd2d.tar.gz |
EPA: do statement with leading semicolon has wrong anchor
The code
do; a <- doAsync; b
Generated an incorrect Anchor for the statement list that starts after
the first semicolon.
This commit fixes it.
Closes #20256
Diffstat (limited to 'compiler/GHC/Parser/PostProcess.hs')
-rw-r--r-- | compiler/GHC/Parser/PostProcess.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs index 8a89bef84d..845f7eb25c 100644 --- a/compiler/GHC/Parser/PostProcess.hs +++ b/compiler/GHC/Parser/PostProcess.hs @@ -39,6 +39,7 @@ module GHC.Parser.PostProcess ( fromSpecTyVarBndr, fromSpecTyVarBndrs, annBinds, fixValbindsAnn, + stmtsAnchor, stmtsLoc, cvBindGroup, cvBindsAndSigs, @@ -478,6 +479,18 @@ fixValbindsAnn EpAnnNotUsed = EpAnnNotUsed fixValbindsAnn (EpAnn anchor (AnnList ma o c r t) cs) = (EpAnn (widenAnchor anchor (map trailingAnnToAddEpAnn t)) (AnnList ma o c r t) cs) +-- | The 'Anchor' for a stmtlist is based on either the location or +-- the first semicolon annotion. +stmtsAnchor :: Located (OrdList AddEpAnn,a) -> Anchor +stmtsAnchor (L l ((ConsOL (AddEpAnn _ (EpaSpan r)) _), _)) + = widenAnchorR (Anchor (realSrcSpan l) UnchangedAnchor) r +stmtsAnchor (L l _) = Anchor (realSrcSpan l) UnchangedAnchor + +stmtsLoc :: Located (OrdList AddEpAnn,a) -> SrcSpan +stmtsLoc (L l ((ConsOL aa _), _)) + = widenSpan l [aa] +stmtsLoc (L l _) = l + {- ********************************************************************** #cvBinds-etc# Converting to @HsBinds@, etc. |