Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#10438 closed bug (fixed)

GHC 7.10.1 panic due to PartialTypeSignatures, TypeFamilies, and local bindings

Reported by: rpglover64 Owned by:
Priority: high Milestone: 7.10.3
Component: Compiler Version: 7.10.1
Keywords: Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Test Case: partial-sigs/should_compile/T10438
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE TypeFamilies #-}
module Bad

foo f = g
  where g r = x
          where x :: _
                x = r

When compiled, it produces the following output:

[1 of 1] Compiling Bad              ( src/Bad.hs, src/Bad.o )

src/Bad.hs:8:22: Warning:
    Found hole ‘_’ with type: w_1
    Where: ‘w_1’ is a rigid type variable bound by
                 the inferred type of g :: w_1 -> w_1 at src/Bad.hs:7:9
    Relevant bindings include
      r :: w_1 (bound at src/Bad.hs:7:11)
      g :: w_1 -> w_1 (bound at src/Bad.hs:7:9)
      f :: t (bound at src/Bad.hs:6:5)
      foo :: t -> w_ -> w_ (bound at src/Bad.hs:6:1)
    In the type signature for ‘x’: _
    In an equation for ‘g’:
        g r
          = x
              x :: _
              x = r
    In an equation for ‘foo’:
        foo f
          = g
              g r
                = x
                    x :: _
                    x = r
ghc: panic! (the 'impossible' happened)
  (GHC version 7.10.1 for x86_64-unknown-linux):
	StgCmmEnv: variable not found
  local binds for:

Please report this as a GHC bug:

Change History (9)

comment:1 Changed 4 years ago by archblob

This does no longer reproduce on current HEAD.

comment:2 Changed 4 years ago by Simon Peyton Jones <simonpj@…>

comment:3 Changed 4 years ago by simonpj

Milestone: 7.10.2
Test Case: partial-sigs/should_compile/T10438

Thanks. I've added a test to make sure it stays good.

I'll re-milestone the ticket for the 7.10 branch, but I don't have time to fix this on the 7.10 branch.

I'll leave the ticket open in case anyone else does. (Finding which patch on HEAD fixed it would be a good start.)


comment:4 Changed 4 years ago by thoughtpolice


Moving to 7.10.3 milestone - if you think this is an error (or a showstopping bug), please remilestone it to 7.10.2 and let us know why.

comment:5 Changed 4 years ago by rpglover64

For reference, this is still an issue in ghc- (i.e. 7.10.2-rc2). And the GADTs extension instead of the TypeFamilies extensions still causes it.

Last edited 4 years ago by rpglover64 (previous) (diff)

comment:6 Changed 4 years ago by rpglover64

If my git bisect was correct, the patch that fixes the problem is "Always generalise a partial type signature".

comment:7 Changed 4 years ago by rpglover64

It seems like cherry picking said patch onto the ghc-7.10 branch fixes the bug (running tests locally now to make sure it doesn't break anything else), but I don't know what the correct workflow is in this case.

comment:8 Changed 4 years ago by simonpj

Status: newmerge

I'll change status to merge, so that if we do 7.10.3 it'll get in.

comment:9 Changed 4 years ago by bgamari

Resolution: fixed
Status: mergeclosed

Merged 28299d6827b334f5337bf5931124abc1e534f33f ("Always generalise a partial type signature") to ghc-7.10.

Last edited 4 years ago by bgamari (previous) (diff)
Note: See TracTickets for help on using tickets.