-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline comment to the last constructor disapears #425
Comments
I added a trace show in The reason is maybe that in GHC module structure last comment is in separate place: data Foo
= Foo -- ^ foo
| Bar -- ^ bar
| Baz -- ^ baz L { abstract:SrcSpan }
( HsModule
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnsModule ""
( AnnList Nothing Nothing Nothing "" "" )
)
( EpaCommentsBalanced ""
[ L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment EpaEofComment { abstract:RealSrcSpan } )
]
)
)
( VirtualBraces 1 ) Nothing Nothing ""
[ L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem "" )
( EpaComments
[ L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- ^ baz" ) { abstract:RealSrcSpan }
)
]
)
) { abstract:SrcSpan }
)
( TyClD NoExtField
( DataDecl
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
[ AddEpAnn AnnData
( EpaSpan { abstract:RealSrcSpan } )
, AddEpAnn AnnEqual
( EpaSpan { abstract:RealSrcSpan } )
]
( EpaComments
[ L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- ^ bar" ) { abstract:RealSrcSpan }
)
, L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- ^ foo" ) { abstract:RealSrcSpan }
)
]
)
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
)
( HsQTvs NoExtField "" ) Prefix
( HsDataDefn NoExtField DataType Nothing Nothing Nothing
[ L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem
[ AddVbarAnn
( EpaSpan { abstract:RealSrcSpan } )
]
)
( EpaComments "" )
) { abstract:SrcSpan }
)
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
, L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem
[ AddVbarAnn
( EpaSpan { abstract:RealSrcSpan } )
]
)
( EpaComments "" )
) { abstract:SrcSpan }
)
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
, L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
] ""
)
)
)
] Nothing Nothing
) compare with standalone comments (for wich we have correct behavior): data Foo
-- | foo
= Foo
-- | Bar
| Bar
-- | Baz
| Baz L { abstract:SrcSpan }
( HsModule
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnsModule ""
( AnnList Nothing Nothing Nothing "" "" )
)
( EpaCommentsBalanced ""
[ L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment EpaEofComment { abstract:RealSrcSpan } )
]
)
)
( VirtualBraces 1 ) Nothing Nothing ""
[ L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem "" )
( EpaComments "" )
) { abstract:SrcSpan }
)
( TyClD NoExtField
( DataDecl
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
[ AddEpAnn AnnData
( EpaSpan { abstract:RealSrcSpan } )
, AddEpAnn AnnEqual
( EpaSpan { abstract:RealSrcSpan } )
]
( EpaComments
[ L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- | baz" ) { abstract:RealSrcSpan }
)
, L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- | bar" ) { abstract:RealSrcSpan }
)
, L
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( EpaComment
( EpaLineComment "-- | foo" ) { abstract:RealSrcSpan }
)
]
)
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
)
( HsQTvs NoExtField "" ) Prefix
( HsDataDefn NoExtField DataType Nothing Nothing Nothing
[ L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem
[ AddVbarAnn
( EpaSpan { abstract:RealSrcSpan } )
]
)
( EpaComments "" )
) { abstract:SrcSpan }
)
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
, L
( SrcSpanAnn
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor )
( AnnListItem
[ AddVbarAnn
( EpaSpan { abstract:RealSrcSpan } )
]
)
( EpaComments "" )
) { abstract:SrcSpan }
)
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
, L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( ConDeclH98
( EpAnn
( Anchor { abstract:RealSrcSpan } UnchangedAnchor ) ""
( EpaComments "" )
)
( L
( SrcSpanAnn EpAnnNotUsed { abstract:SrcSpan } )
( Unqual { abstract:OccName } )
) False "" Nothing
( PrefixCon "" "" ) Nothing
)
] ""
)
)
)
] Nothing Nothing
) Maybe its a GHC parser bug. It seems for me, that the last comment isn't attached to record constructor at all. But I'm very likely to be wrong: I know nothing about GHC internal stucture, that's only what I can guess by theese two examples. Maybe someone more skilled can say something more. |
(with
stylish-haskell 0.14.3.0
):It happens with enums, constructor with fields and records:
after stylish:
The text was updated successfully, but these errors were encountered: