Opened 3 years ago

Closed 2 years ago

#13343 closed bug (fixed)

Levity polymorphism-related GHC panic: expectJust zonkTcTyVarToVar

Reported by: RyanGlScott Owned by: goldfire
Priority: normal Milestone: 8.2.1
Component: Compiler (Type checker) Version: 8.0.1
Keywords: LevityPolymorphism Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash or panic Test Case: typecheck/should_compile/T13343
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Reproducible with GHC 8.0.2 and HEAD:

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

import GHC.Exts

type Bad = forall (v1 :: RuntimeRep) (a1 :: TYPE v). a1
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 8.1.20170223 for x86_64-unknown-linux):
        expectJust zonkTcTyVarToVar
CallStack (from HasCallStack):
  error, called at compiler/utils/Maybes.hs:53:27 in ghc:Maybes
  expectJust, called at compiler/typecheck/TcType.hs:1576:21 in ghc:TcType

Change History (5)

comment:1 Changed 3 years ago by goldfire

I don't have more time to look into precisely why this is getting through the cracks, but that type should be rejected by TcValidity.check_type. Look for the call to forAllEscapeErr.

In short, that type is malformed because it's kind must mention v, which is out-of-scope.

comment:2 Changed 3 years ago by simonpj

Owner: set to goldfire

See comment:10 of #11827 for another example.

comment:3 Changed 3 years ago by Richard Eisenberg <rae@…>

In 02cc8f0/ghc:

Fix #13343 by not defaulting SigTvs

test case: typecheck/should_compile/T13343

comment:4 Changed 3 years ago by goldfire

Milestone: 8.2.1
Status: newmerge
Test Case: typecheck/should_compile/T13343

My comment:1 gets it all wrong, but it was simple in the end.

comment:5 Changed 2 years ago by bgamari

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.