tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
964 stars 81 forks source link

Comment parse error #548

Closed agreif closed 4 years ago

agreif commented 4 years ago

Describe the bug The following correct code throws a parse error

module Main where

-- | Something.                                                                                                                                                                                          

data Foo = Foo
  { fooX :: Int -- ^ X                                                                                                                                                                                   
  , fooY :: Int -- ^ Y                                                                                                                                                                                   

  -- Example app-specific configuration values.                                                                                                                                                          
  -- , appCopyright              :: Text                                                                                                                                                                 
  -- ^ Copyright text to appear in the footer of the page                                                                                                                                                
  -- , appAnalytics              :: Maybe Text                                                                                                                                                           
  -- ^ Google Analytics code                                                                                                                                                                             

  -- , appAuthDummyLogin         :: Bool                                                                                                                                                                 
  -- ^ Indicate if auth dummy login should be enabled.                                                                                                                                                   
  } deriving (Eq, Show)
$ ormolu -p src/Foo.hs 
Parsing of source code failed:
  src/Foo.hs:(11,3)-(13,28)
  parse error on input `-- ^ Copyright text to appear in the footer of the page
  -- , appAnalytics              :: Maybe Text
  -- ^ Google Analytics code'

Environment nixos 19.09

$ ormolu -v
ormolu 0.0.3.1 UNKNOWN UNKNOWN
using ghc-lib-parser 8.10.1.20200412

Additional context this code is generated by a yesod scaffold

mrkkrp commented 4 years ago

This is the GHC parser failing on your input, nothing we can do here. The input should be parsable by GHC with Haddock support enabled. In this particular case it looks like Haddock doesn't like -- ^ in plan comments.