Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associated empty data decl in instance causes error in exactPrint #461

Open
Melvar opened this issue Sep 1, 2021 · 1 comment
Open

Associated empty data decl in instance causes error in exactPrint #461

Melvar opened this issue Sep 1, 2021 · 1 comment

Comments

@Melvar
Copy link

Melvar commented Sep 1, 2021

{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}

instance Foo Bar where
  data Baz Bar

This source file can be parsed just fine, but attempting to exactPrint the resulting module throws an exception:

"{-# LANGUAGE EmptyDataDecls, TypeFamilies #-}\n\ninstance Foo Bar where\n  data Baz Bar*** Exception: ExactP: InstDecl: InsGData is given too few srcInfoPoints
CallStack (from HasCallStack):
  error, called at src/Language/Haskell/Exts/ExactPrint.hs:63:10 in haskell-src-exts-1.23.1-FvLIaTIGxmRVhU8jEdAAL:Language.Haskell.Exts.ExactPrint

It’s a bit suspicious that the parser produced an InsGData (instance GADT declaration) instead of an InsData, even without GADTs enabled. It appears from a cursory inspection of the source that the exact printing implementation for InsGData assumes that a where always needs to be printed, which is violated by the parser in this case but would make sense if an ambiguous empty data declaration is supposed to produce an InsData.

@Melvar
Copy link
Author

Melvar commented Sep 1, 2021

As a bonus, I cannot work around this error by including a where (and GADTs which I am using anyway) because that runs into #358.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant