[Git][ghc/ghc][master] Fix bug wrong span of nested_doc_comment #24378
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Jan 29 22:28:21 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
8eeadfad by Patrick at 2024-01-29T17:27:51-05:00
Fix bug wrong span of nested_doc_comment #24378
close #24378
1. Update the start position of span in `nested_doc_comment` correctly.
and hence the spans of identifiers of haddoc can be computed correctly.
2. add test `HaddockSpanIssueT24378`.
- - - - -
6 changed files:
- compiler/GHC/Parser/Lexer.x
- testsuite/tests/showIface/DocsInHiFile1.stdout
- + testsuite/tests/showIface/HaddockSpanIssueT24378.hs
- + testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
- testsuite/tests/showIface/Makefile
- testsuite/tests/showIface/all.T
Changes:
=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -1485,7 +1485,7 @@ nested_comment span buf len _buf2 = {-# SCC "nested_comment" #-} do
nested_doc_comment :: Action
nested_doc_comment span buf _len _buf2 = {-# SCC "nested_doc_comment" #-} withLexedDocType worker
where
- worker input docType _checkNextLine = nested_comment_logic endComment "" input span
+ worker input@(AI start_loc _) docType _checkNextLine = nested_comment_logic endComment "" input (mkPsSpan start_loc (psSpanEnd span))
where
endComment input lcomment
= docCommentEnd input (docType (\d -> NestedDocString d (mkHsDocStringChunk . dropTrailingDec <$> lcomment))) buf span
=====================================
testsuite/tests/showIface/DocsInHiFile1.stdout
=====================================
@@ -6,11 +6,11 @@ docs:
'<>', ':=:', 'Bool'
-}
identifiers:
- {DocsInHiFile.hs:2:3-6}
+ {DocsInHiFile.hs:2:6-9}
Data.Foldable.elem
- {DocsInHiFile.hs:2:3-6}
+ {DocsInHiFile.hs:2:6-9}
elem
- {DocsInHiFile.hs:2:11-15}
+ {DocsInHiFile.hs:2:14-18}
System.IO.print
{DocsInHiFile.hs:4:2-3}
GHC.Base.<>
=====================================
testsuite/tests/showIface/HaddockSpanIssueT24378.hs
=====================================
@@ -0,0 +1,9 @@
+{-| `elem`, 'print',
+`Unknown',
+'<>', ':=:', 'Bool'
+-}
+module HaddockSpanIssueT24378 ( HaddockSpanIssueT24378.elem) where
+
+{-| '()', 'elem'.-}
+elem :: ()
+elem = ()
=====================================
testsuite/tests/showIface/HaddockSpanIssueT24378.stdout
=====================================
@@ -0,0 +1,83 @@
+docs:
+ Just module header:
+ Just text:
+ {-| `elem`, 'print',
+`Unknown',
+'<>', ':=:', 'Bool'
+-}
+ identifiers:
+ {HaddockSpanIssueT24378.hs:1:6-9}
+ Data.Foldable.elem
+ {HaddockSpanIssueT24378.hs:1:6-9}
+ elem
+ {HaddockSpanIssueT24378.hs:1:14-18}
+ System.IO.print
+ {HaddockSpanIssueT24378.hs:3:2-3}
+ GHC.Base.<>
+ {HaddockSpanIssueT24378.hs:3:15-18}
+ GHC.Types.Bool
+ declaration docs:
+ [elem -> [text:
+ {-| '()', 'elem'.-}
+ identifiers:
+ {HaddockSpanIssueT24378.hs:7:12-15}
+ Data.Foldable.elem
+ {HaddockSpanIssueT24378.hs:7:12-15}
+ elem]]
+ arg docs:
+ []
+ documentation structure:
+ avails:
+ [elem]
+ named chunks:
+ haddock options:
+ language:
+ Nothing
+ language extensions:
+ MonomorphismRestriction
+ RelaxedPolyRec
+ ForeignFunctionInterface
+ ImplicitPrelude
+ ScopedTypeVariables
+ BangPatterns
+ NamedFieldPuns
+ GADTSyntax
+ DoAndIfThenElse
+ ConstraintKinds
+ PolyKinds
+ InstanceSigs
+ StandaloneDeriving
+ DeriveDataTypeable
+ DeriveFunctor
+ DeriveTraversable
+ DeriveFoldable
+ DeriveGeneric
+ DeriveLift
+ TypeSynonymInstances
+ FlexibleContexts
+ FlexibleInstances
+ ConstrainedClassMethods
+ MultiParamTypeClasses
+ ExistentialQuantification
+ EmptyDataDecls
+ KindSignatures
+ GeneralizedNewtypeDeriving
+ PostfixOperators
+ TupleSections
+ PatternGuards
+ RankNTypes
+ TypeOperators
+ ExplicitForAll
+ TraditionalRecordSyntax
+ BinaryLiterals
+ HexFloatLiterals
+ EmptyCase
+ NamedWildCards
+ TypeApplications
+ EmptyDataDeriving
+ NumericUnderscores
+ StarIsType
+ ImportQualifiedPost
+ StandaloneKindSignatures
+ FieldSelectors
+extensible fields:
=====================================
testsuite/tests/showIface/Makefile
=====================================
@@ -42,6 +42,10 @@ HaddockIssue849:
'$(TEST_HC)' $(TEST_HC_OPTS) -c -haddock HaddockIssue849.hs
'$(TEST_HC)' $(TEST_HC_OPTS) --show-iface HaddockIssue849.hi | grep -A 200 'docs:'
+HaddockSpanIssueT24378:
+ '$(TEST_HC)' $(TEST_HC_OPTS) -c -haddock HaddockSpanIssueT24378.hs
+ '$(TEST_HC)' $(TEST_HC_OPTS) --show-iface HaddockSpanIssueT24378.hi | grep -A 200 'docs:'
+
MagicHashInHaddocks:
'$(TEST_HC)' $(TEST_HC_OPTS) -c -haddock MagicHashInHaddocks.hs
'$(TEST_HC)' $(TEST_HC_OPTS) --show-iface MagicHashInHaddocks.hi | grep -A 200 'docs:'
=====================================
testsuite/tests/showIface/all.T
=====================================
@@ -11,4 +11,5 @@ test('HaddockOpts', normal, makefile_test, [])
test('LanguageExts', normal, makefile_test, [])
test('ReExports', extra_files(['Inner0.hs', 'Inner1.hs', 'Inner2.hs', 'Inner3.hs', 'Inner4.hs']), makefile_test, [])
test('HaddockIssue849', normal, makefile_test, [])
+test('HaddockSpanIssueT24378', normal, makefile_test, [])
test('MagicHashInHaddocks', normal, makefile_test, [])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8eeadfad3a0035f8c5b339782676ff23572e0e5e
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8eeadfad3a0035f8c5b339782676ff23572e0e5e
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240129/f06de3dd/attachment-0001.html>
More information about the ghc-commits
mailing list