[GHC] #14154: Some cocktail of features causes GHC panic

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{ {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-} import Data.Coerce newtype Ran g h a = Ran (forall b. (a -> g b) -> h b) newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show class IxPointed m where ireturn :: a -> m i i a instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i) instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a) xs = case ireturn @(Swap Main.Ran) 'a' of Swap (Ran f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: Old description:
{{{ {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-}
import Data.Coerce
newtype Ran g h a = Ran (forall b. (a -> g b) -> h b)
newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show
class IxPointed m where ireturn :: a -> m i i a
instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i)
instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a)
xs = case ireturn @(Swap Main.Ran) 'a' of Swap (Ran f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-} import Data.Coerce newtype Ran g h a = Ran (forall b. (a -> g b) -> h b) newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show class IxPointed m where ireturn :: a -> m i i a instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i) instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a) xs = case ireturn @(Swap Main.Ran) 'a' of Swap (Ran f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by Iceland_jack: Old description:
{{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-}
import Data.Coerce
newtype Ran g h a = Ran (forall b. (a -> g b) -> h b)
newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show
class IxPointed m where ireturn :: a -> m i i a
instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i)
instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a)
xs = case ireturn @(Swap Main.Ran) 'a' of Swap (Ran f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-} import Data.Coerce newtype Ran g h a = Ran (forall b. (a -> g b) -> h b) newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show class IxPointed m where ireturn :: a -> m i i a instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i) instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a) xs = case ireturn @(Swap Ran) 'a' of Swap (Ran f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by simonpj: Old description:
{{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, PolyKinds #-}
import Data.Coerce
newtype Ran g h a = Ran (forall b. (a -> g b) -> h b)
newtype Swap p f g a where Swap :: p g f a -> Swap p f g a deriving newtype Show
class IxPointed m where ireturn :: a -> m i i a
instance IxPointed f => IxPointed (Swap f) where ireturn :: forall a i. a -> Swap f i i a ireturn = coerce (ireturn @f @a @i)
instance IxPointed Ran where ireturn :: a -> Ran i i a ireturn a = Ran (\k -> k a)
xs = case ireturn @(Swap Ran) 'a' of Swap (Ran f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-} module T14154 where newtype Ran g h a = Ran (forall b. (a -> g b) -> h b) newtype Swap p f g a where Swap :: p g f a -> Swap p f g a ireturn :: forall m i a. a -> m i i a ireturn = undefined xs = case ireturn @(Swap Ran) 'a' of Swap (Ran f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by simonpj: Old description:
{{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-}
module T14154 where
newtype Ran g h a = Ran (forall b. (a -> g b) -> h b)
newtype Swap p f g a where Swap :: p g f a -> Swap p f g a
ireturn :: forall m i a. a -> m i i a ireturn = undefined
xs = case ireturn @(Swap Ran) 'a' of Swap (Ran f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-} module T14154 where newtype Ran g h a = MkRan (forall b. (a -> g b) -> h b) newtype Swap p f g a where MkSwap :: p g f a -> Swap p f g a ireturn :: forall m i a. a -> m i i a ireturn = undefined xs = case ireturn @(Swap Ran) 'a' of MkSwap (MkRan f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: RyanGlScott (added) * version: 8.3 => 8.0.1 Old description:
{{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-}
module T14154 where
newtype Ran g h a = MkRan (forall b. (a -> g b) -> h b)
newtype Swap p f g a where MkSwap :: p g f a -> Swap p f g a
ireturn :: forall m i a. a -> m i i a ireturn = undefined
xs = case ireturn @(Swap Ran) 'a' of MkSwap (MkRan f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-} module T14154 where newtype Ran g h a = MkRan (forall b. (a -> g b) -> h b) newtype Swap p f g a where MkSwap :: p g f a -> Swap p f g a ireturn :: forall m i a. a -> m i i a ireturn = undefined xs = case ireturn @(Swap Ran) 'a' of MkSwap (MkRan f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- Comment: Interesting! This appears to be an old bug, since it happens all the way back in GHC 8.0.1 (that's as far back as I can go, since `TypeApplications` didn't exist before then). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * cc: RyanGlScott (removed) * version: 8.0.1 => 8.3 Old description:
{{{#!hs {-# Language RankNTypes, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-}
module T14154 where
newtype Ran g h a = MkRan (forall b. (a -> g b) -> h b)
newtype Swap p f g a where MkSwap :: p g f a -> Swap p f g a
ireturn :: forall m i a. a -> m i i a ireturn = undefined
xs = case ireturn @(Swap Ran) 'a' of MkSwap (MkRan f) -> f print }}}
{{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}}
New description: {{{#!hs {-# Language RankNTypes, DerivingStrategies, TypeApplications, ScopedTypeVariables, GADTs, PolyKinds #-} module T14154 where newtype Ran g h a = MkRan (forall b. (a -> g b) -> h b) newtype Swap p f g a where MkSwap :: p g f a -> Swap p f g a ireturn :: forall m i a. a -> m i i a ireturn = undefined xs = case ireturn @(Swap Ran) 'a' of MkSwap (MkRan f) -> f print }}} {{{ $ ghci -ignore-dot-ghci /tmp/bug.hs GHCi, version 8.3.20170605: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( /tmp/bug.hs, interpreted ) ghc: panic! (the 'impossible' happened) (GHC version 8.3.20170605 for x86_64-unknown-linux): piResultTy k0_a1Ki[tau:2] b0_a1Kt[tau:2] Call stack: CallStack (from HasCallStack): prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable pprPanic, called at compiler/types/Type.hs:949:35 in ghc:Type Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
}}} -- Comment: I have worked out what is happening here. * We have {{{ ireturn :: forall k (m :: k -> k -> * -> *) a (i :: k). a -> m i i a }}} * At the call of `ireturn` in `xs` we instantiate `k`,`m`,`a`,`i` with unification variables `k0`, `m0 :: k0 -> k0 -> k* -> *`, `a0`, `i0 :: k0`. * The visible type application ends up forcing `k0 := k1 -> *` * In the pattern `MkRan f` we end up with expected type `Ran k0 i0 i0 a0` * The definition of `Ran` is {{{ newtype Ran k (g :: k -> *) (h :: k -> *) a where MkRan :: forall k (g :: k -> *) (h :: k -> *) a. (forall (b :: k). (a -> g b) -> h b) -> Ran k g h a }}} * So, in `TcPat.tcDataConPat` we instantiate `k :-> k0, g :-> i0, h :-> i0, a :-> a0`. * But now, in the instantiated version of `MkRan`'s type we have `i0 b`, ''which is ill-kinded''. At least, it's ill-kinded until we zonk everything. But the type constraint solver calls `typeKind` on un-zonked types quite a bit. * `typeKind` is non-monadic and crashes on ill-kinded types, via the call to `piResultTy` {{{ typeKind (AppTy fun arg) = piResultTy (typeKind fun) arg }}} * FWIW the crashing call to `typeKind` is in `TcUnify.promoteTcType`. Now, I believe our invariant is that ''we never form an ill-kinded type'', zonked or unzonked. In this example we don't obey the invariant. What could we do? * In the offending `tcDataConPat` we could instantiate the data contructor's type with fresh unification variables, and emit equalities to link it up with the "expected" type `ctxt_res_tys`. * We could do that in the general case, but have a short-cut for the common case where the kinds do actually match up. * We could give up on the invariant; where we need `typeKind` and it fails, we could generate a unification variable, and emit a new kind of delayed constraint that means `kappa ~ kindof( ty )`. Yuk. Richard, any other ideas? What is unsettling is that I can't see how to be sure there are no other lurking cases of this same problem, elsewhere in the typechecker. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Could we fix one case this with a well-placed zonk? More broadly (re: could this happen elsewhere?) I've grown increasingly uncomfortable with the way GHC handles tyvars and zonking. When the type- checker fills in a metavariable, it then assumes that the metavar and its new value are equal. Except, of course, pure code can (and will, to our dismay) spot the difference. So, we could make `tc` versions of various type-manipulation functions (we indeed already do) and make them monadic, looking through metavars (this bit is new). That's disappointing, somehow. But I don't really see a better option. If we did this -- and did it reliably -- I think we could remove `zonkTcType` and friends (keeping only `zonkTcTypeToType` and friends). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Could we fix one case this with a well-placed zonk?
I suppose we could always zonk before calling `typeKind`. But I am deeply averse to doing this. * The constraint solver does zonking on the fly, as part of canonicalisation. That is simple and nice. I don't think we should ''ever'' call zonking when we are solving constraints. * I think the constraint solver indeed obeys the invariant that we never constructor an ill-kinded type, provided you ''don't'' zonk it! But, as remarked above, `tcDataConPat` does form an ill-kinded type. I think right solution is not do to so, which isn't difficult. What I'm upset about is that it's hard to be sure when we have nailed every case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Would an `ASSERT` in `mkAppTy` do it? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): An assert in every smart type constuctor `mkTyConApp`, `mkFunTy` etc, that checked that the type was well kinded, yes. `mkAppTy` is just one example. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T14154 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge * testcase: => typecheck/should_compile/T14154 * milestone: => 8.2.2 Comment: Probably small enough to merge. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14154: Some cocktail of features causes GHC panic -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.2 Component: Compiler | Version: 8.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_compile/T14154 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Indeed, merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14154#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC