Ticket #138 (new defect)

Opened 4 years ago

Last modified 19 months ago

Malformed or missing comments in files with #line directive

Reported by: jmillikin Owned by:
Priority: major Milestone:
Version: Keywords:
Cc: haskell.org@…


Using an example file with #line directives:

module Test(Data(..), func) where

#line 40 "test.cpphs"
-- | data 'Data'
data Data = Data

#line 30 "test.cpphs"
-- | Function 'func'

#line 20 "test.cpphs"
func :: Data
func = Data

The documentation for foo will be rendered attached to Data. I feel this is incorrect, as func :: Data is the next line after -- | Function 'func'.

There's no 2.7.2 version available, so I'm leaving that field blank.

Change History

Changed 4 years ago by simonmar

Arguably the behaviour is correct, because the source is presumably preprocessed from an original which looks something like

module Test(Data(..), func) where

func :: Data
func = Data

-- | Function 'func'

-- | data 'Data'
data Data = Data

Changed 2 years ago by liyang

  • cc haskell.org@… added

Likely related: I have some .hsc files that get expanded to something like the following:

module Lines where

#line 100
-- | cow.
cow :: ()
cow = ()

#line 101
-- | moo.
moo :: ()
moo = ()

Unfortunately haddock attributes both comments to cow. Weirder still, removing the comment for moo puts it before cow in the output (because both are now defined on lines 101–102?), while the comment for cow is now attached to moo.

Wouldn't it be simpler and more predictable for haddock to just ignore any line directives? If some arbitrary preprocessor severs a comment from its intended target, it's a losing game to try to infer where it ought to have gone.

Changed 19 months ago by anonymous

  • milestone 2.7.0 deleted

Milestone 2.7.0 deleted

Note: See TracTickets for help on using tickets.