Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,866
    • Issues 4,866
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17305
Closed
Open
Created Oct 04, 2019 by Ryan Scott@RyanGlScottMaintainer

Data family instances aren't eta-reduced correctly

(I originally discovered this when debugging #17296 (closed)/!1877 (closed), but this doesn't rely on !1877 (closed) to reproduce.)

Take this code:

{-# LANGUAGE GADTs #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where

import Data.Kind
import Language.Haskell.TH hiding (Type)
import System.IO

data family Foo a
data instance Foo :: Type -> Type where
  MkFoo :: Foo a

$(do i <- reify ''Foo
     runIO $ hPutStrLn stderr $ pprint i
     pure [])

And compile it with a devel2-flavoured compiler. (I'm on commit d0924b15.) You'll get the following panic:

$ ~/Software/ghc3/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o, Bug.dyn_o )

Bug.hs:1:1: error:
    Exception when trying to run compile-time code:
      ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.9.0.20191003:
        zipEqual: unequal lists:zipTyEnv

Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

    Code: do i <- reify ''Foo
             runIO $ hPutStrLn stderr $ pprint i
             pure []
  |
1 | {-# LANGUAGE GADTs #-}
  | ^
Edited Apr 02, 2020 by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking