diff options
-rw-r--r-- | compiler/parser/Parser.y | 13 | ||||
-rw-r--r-- | testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr | 13 | ||||
-rw-r--r-- | testsuite/tests/haddock/should_compile_flag_haddock/all.T | 1 | ||||
m--------- | utils/haddock | 0 |
5 files changed, 35 insertions, 5 deletions
diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index 9489be4ced..ef1c3ec160 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -1727,9 +1727,9 @@ inst_type :: { LHsSigType RdrName } : sigtype { mkLHsSigType $1 } deriv_types :: { [LHsSigType RdrName] } - : type { [mkLHsSigType $1] } + : typedoc { [mkLHsSigType $1] } - | type ',' deriv_types {% addAnnotation (gl $1) AnnComma (gl $2) + | typedoc ',' deriv_types {% addAnnotation (gl $1) AnnComma (gl $2) >> return (mkLHsSigType $1 : $3) } comma_types0 :: { [LHsType RdrName] } -- Zero or more: ty,ty,ty @@ -1936,10 +1936,9 @@ fielddecl :: { LConDeclField RdrName } -- know the rightmost extremity of the 'deriving' clause deriving :: { Located (HsDeriving RdrName) } : {- empty -} { noLoc Nothing } - | 'deriving' qtycon {% let { L tv_loc tv = $2 - ; full_loc = comb2 $1 $> } + | 'deriving' qtycondoc {% let { full_loc = comb2 $1 $> } in ams (L full_loc $ Just $ L full_loc $ - [mkLHsSigType (L tv_loc (HsTyVar $2))]) + [mkLHsSigType $2]) [mj AnnDeriving $1] } | 'deriving' '(' ')' {% let { full_loc = comb2 $1 $> } @@ -2896,6 +2895,10 @@ qtycon :: { Located RdrName } -- Qualified or unqualified : QCONID { sL1 $1 $! mkQual tcClsName (getQCONID $1) } | tycon { $1 } +qtycondoc :: { LHsType RdrName } -- Qualified or unqualified + : qtycon { sL1 $1 (HsTyVar $1) } + | qtycon docprev { sLL $1 $> (HsDocTy (sL1 $1 (HsTyVar $1)) $2) } + tycon :: { Located RdrName } -- Unqualified : CONID { sL1 $1 $! mkUnqual tcClsName (getCONID $1) } diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs b/testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs new file mode 100644 index 0000000000..5689b42380 --- /dev/null +++ b/testsuite/tests/haddock/should_compile_flag_haddock/T11768.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE StandaloneDeriving #-} +module T11768 where + +data Foo = Foo + deriving Eq -- ^ Documenting a single type + +data Bar = Bar + deriving ( Eq -- ^ Documenting one of multiple types + , Ord + ) + +-- | Documenting a standalone deriving instance +deriving instance Read Bar diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr new file mode 100644 index 0000000000..684a6f072a --- /dev/null +++ b/testsuite/tests/haddock/should_compile_flag_haddock/T11768.stderr @@ -0,0 +1,13 @@ + +==================== Parser ==================== +module T11768 where +data Foo + = Foo + deriving (Eq Documenting a single type) +data Bar + = Bar + deriving (Eq Documenting one of multiple types, Ord) +<document comment> +deriving instance Read Bar + + diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/all.T b/testsuite/tests/haddock/should_compile_flag_haddock/all.T index 344210e1a0..7db4379b16 100644 --- a/testsuite/tests/haddock/should_compile_flag_haddock/all.T +++ b/testsuite/tests/haddock/should_compile_flag_haddock/all.T @@ -46,3 +46,4 @@ test('haddockA032', normal, compile, ['-haddock -ddump-parsed']) test('haddockA033', normal, compile, ['-haddock -ddump-parsed']) test('haddockA034', normal, compile, ['-haddock -ddump-parsed']) test('T10398', normal, compile, ['-haddock -ddump-parsed']) +test('T11768', normal, compile, ['-haddock -ddump-parsed']) diff --git a/utils/haddock b/utils/haddock -Subproject 9760ee9efe22f0256d626bc567a7adfc754e906 +Subproject d7ef90898c6d8ddeae23caf0f9fb68c25537dcd |