summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2023-02-06 22:58:39 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-02-08 18:42:51 -0500
commitf22cce70dc7b9da191a023a9677eaea491bb2688 (patch)
tree2c86b3ec052594b1f2d14daca31f5f6ccf275676 /compiler/GHC/Parser
parentca6673e3cab496bbeed2ced47b40bcf1e0d0b3cd (diff)
downloadhaskell-f22cce70dc7b9da191a023a9677eaea491bb2688.tar.gz
EPA: Comment between module and where should be in header comments
Do not apply the heuristic to associate a comment with a prior declaration for the first declaration in the file. Closes #22919
Diffstat (limited to 'compiler/GHC/Parser')
-rw-r--r--compiler/GHC/Parser/Lexer.x6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/GHC/Parser/Lexer.x b/compiler/GHC/Parser/Lexer.x
index 407aa93280..1fd2c5b663 100644
--- a/compiler/GHC/Parser/Lexer.x
+++ b/compiler/GHC/Parser/Lexer.x
@@ -3700,11 +3700,13 @@ allocatePriorComments ss comment_q mheader_comments =
cmp (L l _) = anchor l <= ss
(newAnns,after) = partition cmp comment_q
comment_q'= after
- (prior_comments, decl_comments) = splitPriorComments ss newAnns
+ (prior_comments, decl_comments)
+ = case mheader_comments of
+ Strict.Nothing -> (reverse newAnns, [])
+ _ -> splitPriorComments ss newAnns
in
case mheader_comments of
Strict.Nothing -> (Strict.Just prior_comments, comment_q', decl_comments)
- -- Strict.Nothing -> (Strict.Just [], comment_q', newAnns)
Strict.Just _ -> (mheader_comments, comment_q', reverse newAnns)
allocateFinalComments