Opened 7 months ago

Last modified 6 months ago

#16347 new bug

GHC HEAD regression: piResultTys1

Reported by: RyanGlScott Owned by:
Priority: highest Milestone:
Component: Compiler (Type checker) Version: 8.7
Keywords: TypeInType Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description (last modified by RyanGlScott)

The following program typechecks on GHC 8.0.2 through 8.6.3, but panics on HEAD:

{-# LANGUAGE GADTs      #-}
{-# LANGUAGE TypeInType #-}
module Bug where

import Data.Kind

data T f :: f Type -> Type where
  MkT :: T f a
$ ~/Software/ghc4/inplace/bin/ghc-stage2 Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.7.20190219 for x86_64-unknown-linux):
        piResultTys1
  k_a10k[tau:1]
  [*]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1159:37 in ghc:Outputable
        pprPanic, called at compiler/types/Type.hs:1063:5 in ghc:Type

Change History (5)

comment:1 Changed 7 months ago by RyanGlScott

Description: modified (diff)

comment:2 Changed 7 months ago by RyanGlScott

Cc: simonpj added

This regression was introduced in commit 682783828275cca5fd8bf5be5b52054c75e0e22c (Make a smart mkAppTyM).

comment:3 Changed 7 months ago by simonpj

Interestingly this is a consequence of the broken-ness described in #16344. Fixing the latter fixes this ticket too.

comment:4 Changed 7 months ago by goldfire

In conversation, Simon and I uncovered an unstated invariant: the tyVarKind of occurrences of a bound tyvar must share the tyVarKind of the binding site. In this example, that is not the case, because the kind of the tyvar contains a metavariable; it is zonked at an occurrence but not at the binding site.

The fix is easy: do an extra zonk in kcLHsQTyVars_NonCusk, but fixing #16344 will also make this problem melt away.

comment:5 Changed 6 months ago by Marge Bot <ben+marge-bot@…>

In 4db9bdd9/ghc:

Add regression test for #16347

Commit 1f5cc9dc8aeeafa439d6d12c3c4565ada524b926 ended up
fixing #16347. Let's add a regression test to ensure that it stays
fixed.
Note: See TracTickets for help on using tickets.