Opened 3 years ago

Closed 3 years ago

#7128 closed bug (fixed)

Panic "lookupVarEnv_NF" when using a functional dependency with a kind variable

Reported by: goldfire Owned by:
Priority: normal Milestone: 7.6.1
Component: Compiler Version: 7.5
Keywords: PolyKinds FunctionalDependencies Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: polykinds/T7128
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

The following code causes a panic:

{-# LANGUAGE PolyKinds, DataKinds, MultiParamTypeClasses,
             FunctionalDependencies
 #-}

class Foo a (b :: k) | a -> k
instance Foo Bool False

The error is

ghc-stage2: panic! (the 'impossible' happened)
  (GHC version 7.7.20120807 for x86_64-apple-darwin):
	lookupVarEnv_NF: Nothing

In previous versions of GHC 7.5.x, a functional dependency of this nature worked just fine and had the expected behavior of fixing the value of k once a was known. It's unclear to me whether this should compile or not, but it shouldn't cause a panic. I believe that my code that used the functional dependency could use a -> b in place of a -> k with no ill effect, so turning this into an error is not a problem.

Change History (3)

comment:1 Changed 3 years ago by simonpj@…

commit e949162653b65d8e48573e84583c6509be2f24ed

Author: Simon Peyton Jones <[email protected]>
Date:   Tue Aug 14 17:06:00 2012 +0100

    Fix Trac #7128, by zonking kind varaibles more assiduously when typechecking a class declaration

 compiler/typecheck/TcHsSyn.lhs      |    2 +-
 compiler/typecheck/TcTyClsDecls.lhs |   19 +++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

comment:2 Changed 3 years ago by simonpj

  • difficulty set to Unknown
  • Status changed from new to merge
  • Test Case set to polykinds/T7128

Good bug report. Yes it should work, and now it does.

Please merge this to 7.6

Simon

comment:3 Changed 3 years ago by pcapriotti

  • Milestone set to 7.6.1
  • Resolution set to fixed
  • Status changed from merge to closed
Note: See TracTickets for help on using tickets.