Skip to content

GHC panic with visible kind applications

Using the https://phabricator.haskell.org/D5229 diff

This is fine

{-# Language RankNTypes       #-}
{-# Language TypeApplications #-}
{-# Language PolyKinds        #-}
{-# Language GADTs            #-}

import Data.Kind

data
  App :: forall (f :: Type -> Type). Type -> Type
  where
  MkApp :: f a -> App @f a

Kind polymorphic is fine

{-# Language RankNTypes       #-}
{-# Language TypeApplications #-}
{-# Language PolyKinds        #-}
{-# Language GADTs            #-}

import Data.Kind

data
  App :: forall k (f :: k -> Type). k -> Type
  where
  MkApp :: f a -> App @k @(f :: k -> Type) (a :: k)

But offing the visibility of k fails

{-# Language RankNTypes       #-}
{-# Language TypeApplications #-}
{-# Language PolyKinds        #-}
{-# Language GADTs            #-}

import Data.Kind

data
  App :: forall (f :: k -> Type). k -> Type
  where
  MkApp :: f a -> App @(f :: k -> Type) (a :: k)
{-# Language RankNTypes       #-}
{-# Language TypeApplications #-}
{-# Language PolyKinds        #-}
{-# Language GADTs            #-}

import Data.Kind

data
  App :: forall (f :: k -> Type). k -> Type
  where
  MkApp :: f a -> App @f a
$ ghci -ignore-dot-ghci 581_bug.hs
GHCi, version 8.7.20181017: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( 581_bug.hs, interpreted )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.7.20181017 for x86_64-unknown-linux):
        ASSERT failed!
  2
  1
  f_a1yB[tau:1]
  f_a1yx[sk:1]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1160:37 in ghc:Outputable
        pprPanic, called at compiler/utils/Outputable.hs:1219:5 in ghc:Outputable
        assertPprPanic, called at compiler/typecheck/TcMType.hs:778:54 in ghc:TcMType

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

> 
Trac metadata
Trac field Value
Version 8.6.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC mnguyen
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information