Ticket #10 (assigned defect)

Opened 6 years ago

Last modified 2 years ago

Parsing module without explicit module declaration fails

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

Description (last modified by SimonHengel) (diff)

If a module does not contain an explicit module declaration and starts with

-- | some comment

then parsing fails.

This is a bug in GHC's parser. It is only triggered if Opt_Haddock is used.

Details

GHC's parser has a rule for Haddock comments on module headers. When the parser sees the Haddock comment at the beginning it then wants the next declaration to be a module header (the grammar has an S/R conflict because of this).

One possible solution could be to parse Haddock comments separately from the Haskell code, and match up Haddock comments with AST nodes in a later step.

Steps to reproduce

-- | Hi there
main = print "Hello World!"

Running

$ haddock Main.hs

fails with:

Main.hs:2:1: parse error on input `main'

In contrast both of the following example work just fine:

{-
Hi there
-}
main = print "Hello World!"
foo = 23
-- | Hi there
main = print "Hello World!"

Change History

Changed 6 years ago by waern

  • version changed from 2.1.0 to 0.x series
  • description modified (diff)

Changed 6 years ago by anonymous

  • summary changed from Starting the module with -- | doc followed by declaration doesn't parse to Starting the module with -- | doc followed by a declaration doesn't parse

Changed 6 years ago by anonymous

  • priority changed from minor to major

Changed 6 years ago by waern

  • milestone set to _|_

Changed 2 years ago by SimonHengel

  • owner set to SimonHengel
  • status changed from new to assigned

Changed 2 years ago by SimonHengel

  • description modified (diff)
  • summary changed from Starting the module with -- | doc followed by a declaration doesn't parse to Modules without an explicit module declaration can not be parsed

Changed 2 years ago by SimonHengel

  • summary changed from Modules without an explicit module declaration can not be parsed to Parsing fails for modules without explicit module declaration

Changed 2 years ago by SimonHengel

  • description modified (diff)
  • summary changed from Parsing fails for modules without explicit module declaration to Parsing module without explicit module declaration fails

Changed 2 years ago by SimonHengel

  • version 0.x deleted

#197 is a duplicate of this.

Note: See TracTickets for help on using tickets.