Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#13871 closed bug (fixed)

GHC panic in 8.2 only: typeIsTypeable(Coercion)

Reported by: RyanGlScott Owned by: bgamari
Priority: high Milestone: 8.2.1
Component: Compiler (Type checker) Version: 8.2.1-rc2
Keywords: TypeInType, Typeable Cc: bgamari
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: typecheck/should_compile/T13871
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D3671, Phab:D3672
Wiki Page:

Description

This code works fine in GHC 8.0.1 and 8.0.2:

{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
module Foo where

import Data.Kind

data Foo (a :: Type) (b :: Type) where
  MkFoo :: (a ~ Int, b ~ Char) => Foo a b

data family Sing (a :: k)
data SFoo (z :: Foo a b) where
  SMkFoo :: SFoo MkFoo

But in GHC 8.2 and HEAD, it panics:

$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.0.20170622: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Foo              ( Bug.hs, interpreted )
ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.0.20170622 for x86_64-unknown-linux):
	typeIsTypeable(Coercion)

Change History (9)

comment:1 Changed 5 months ago by RyanGlScott

Cc: bgamari added

Commit 8fa4bf9ab3f4ea4b208f4a43cc90857987e6d497 (Type-indexed Typeable) caused this.

comment:2 Changed 5 months ago by bgamari

Owner: set to bgamari
Test Case: typecheck/should_compile/T13871

Oh dear, yes, I was slightly worried about issues like this.

comment:3 Changed 5 months ago by bgamari

Differential Rev(s): Phab:D3671, Phab:D3672
Status: newpatch

comment:4 Changed 5 months ago by Ben Gamari <ben@…>

In 12a3c39/ghc:

testsuite: Add broken test for #13871

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #13871

Differential Revision: https://phabricator.haskell.org/D3671

comment:5 Changed 5 months ago by Ben Gamari <ben@…>

In 13465254/ghc:

typecheck: Consider types containing coercions non-Typeable

This was previously a panic and caused #13871. I believe just saying
these types simply aren't Typeable should be correct.

Test Plan: Validate, check `T13871`

Reviewers: goldfire, austin

Subscribers: rwbarton, thomie, RyanGlScott

GHC Trac Issues: #13871

Differential Revision: https://phabricator.haskell.org/D3672

comment:6 Changed 5 months ago by bgamari

Status: patchmerge

comment:7 Changed 5 months ago by bgamari

Resolution: fixed
Status: mergeclosed

comment:8 Changed 5 months ago by goldfire

I take it as an eventual goal to have all types be Typeable. Is there a ticket requesting support for types with casts/coercions? I don't think it would be terribly hard to do.

comment:9 Changed 5 months ago by bgamari

I don't believe there is one.

Note: See TracTickets for help on using tickets.