Skip to content

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

Open
@Melvar

Description

@Melvar
{-# 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions