haskell-suite / haskell-src-exts

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

Parse Error on empty closed type families #438

Open JakobBruenker opened 5 years ago

JakobBruenker commented 5 years ago

GHC parses the following file just fine, but using haskell-src-exts' parseFile results in a Parse Error:

{-# LANGUAGE TypeFamilies #-}

type family Test where

If you add a line like

  Test = ()

To the end of this file, parseFile works.

Empty closed type families can be useful when the return type is void, as in

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}

import Data.Type.Equality
import Data.Void

type family OneIsn'tZero (p :: 1 :~: 0) :: Void where

This is also how I encountered this bug.

This might be related to https://github.com/haskell-suite/haskell-src-exts/issues/358

Version: Both 1.21.0 on hackage and the master branch.