haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

#371, fix multiline LANGUAGE pragmas #408

Open bravit opened 6 years ago

bravit commented 6 years ago

The following code (multiline LANGUAGE pragma with lines started with non-whitespace characters) :

{-# LANGUAGE
BangPatterns,
MagicHash
,OverloadedStrings
,  LambdaCase
  #-}

makes lexer to insert ; in the beginning of every line. This can be fixed by workaround in the parser. The first attempt was made in #217, here I follow the same approach.

mpickering commented 6 years ago

I don't think this is right as you can't write

{-# LANGUAGE  RecordWildCard;, TemplateHaskell #-}

test.hs:1:30: error:
    Cannot parse LANGUAGE pragma
    Expecting comma-separated list of language options,
    each starting with a capital letter
      E.g. {-# LANGUAGE TemplateHaskell, GADTs #-}
  |
1 | {-# LANGUAGE  RecordWildCards;, TemplateHaskell #-}
  |                              ^
Failed, no modules loaded.
Prelude> Leaving GHCi.

This is a bug in the lexer which I have not being able to fix, similar to all the other issues tagged with "layout" https://github.com/haskell-suite/haskell-src-exts/issues?q=is%3Aissue+is%3Aopen+label%3Alayout