Ticket #10 (assigned defect)
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!"
