Ticket #94 (new enhancement)

Opened 6 years ago

Last modified 3 years ago

Give a useful warning message instead of a cryptic parse error when encountering unexpected Haddock comments

Reported by: waern Owned by:
Priority: major Milestone: _|_
Version: Keywords:
Cc:

Description (last modified by waern) (diff)

See this failure when processing XMonad:

XMonad/Layout.hs:55:19: parse error on input `!' haddock: Failed to check module: XMonad.Layout

The relevant lines:

data Tall a = Tall !Int -- ^ The default number of windows in the master pane (default: 1)
                   !Rational -- ^ Default proportion of screen occupied by master pane (default: 1/2)
                   !Rational; -- ^ Percent of screen to increment by when resizing panes (default: 3/100)

Since we don't support Haddock comments on individual arguments of constructors, this just fails with a parse error. Perhaps we should give a warning message instead. In general, it would be good if we give a warning message instead of a parse error whenever a Haddock comment is encountered where it is not expected.

I think implementing this is hard, given the way things currently work. Haddock comments are just ordinary tokens that are fed to the parser in GHC, and we clearly don't want put them all over the grammar. If we should move to a design where Haddock comments are not in the grammar, but are collected elsewhere, implementing this ticket would be easier.

Change History

Changed 6 years ago by waern

  • description modified (diff)

Changed 6 years ago by waern

We could also insert warnings for special cases like the above example which trips people up a lot. That could be done using the current parser, I think.

Changed 6 years ago by waern

  • description modified (diff)

Changed 5 years ago by waern

  • priority changed from major to critical
  • summary changed from Give a warning message instead of an error when encountering unexpected Haddock comments to Give a useful warning message instead of a cryptic parse error when encountering unexpected Haddock comments

Changed 3 years ago by waern

  • priority changed from critical to major
Note: See TracTickets for help on using tickets.