zonkTcTyVarToTcTyVar compiler panic with PartialTypeSignatures
See also #26030 (closed)
Summary
I ran into a compiler panic that I managed to shrink down to a problem with PartialTypeSignatures. The panicking code shouldn't compile, but it probably shouldn't panic either.
Steps to reproduce
Attempt to compile the following code with ghc 9.12.2:
{-# LANGUAGE PartialTypeSignatures #-}
module MyLib () where
fails :: _ => a
fails = id $ ()
I also have a haskell playground version where you can see the issue here: https://play.haskell.org/saved/c59WjUrS
In ghc 9.12.2 on the playground the error is
<no location info>: error:
panic! (the 'impossible' happened)
GHC version 9.12.2:
zonkTcTyVarToTcTyVar
a_awz[tyv:1]
()
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Panic.hs:190:37 in ghc-9.12.2-5327:GHC.Utils.Panic
pprPanic, called at compiler/GHC/Tc/Zonk/TcType.hs:277:34 in ghc-9.12.2-5327:GHC.Tc.Zonk.TcType
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
The panic goes away if I remove the partial type signature or the $
.
Expected behavior
The code should fail like it does in ghc 9.10 with an error like
Main.hs:5:9: error: [GHC-25897]
• Couldn't match expected type ‘a’ with actual type ‘()’
‘a’ is a rigid type variable bound by
the inferred type of fails :: a
at Main.hs:4:1-15
• In the expression: id $ ()
In an equation for ‘fails’: fails = id $ ()
• Relevant bindings include fails :: a (bound at Main.hs:5:1)
|
5 | fails = id $ ()
| ^^^^^^^
Environment
- GHC version used: 9.12.2
Optional:
- Operating System:
- System Architecture:
Edited by Simon Peyton Jones