Opened 11 years ago

Closed 11 years ago

#2649 closed bug (fixed)

6.10 regression: panic in tyFamInsts on invalid code

Reported by: Deewiant Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.9
Keywords: Cc:
Operating System: Windows Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

{-# LANGUAGE ScopedTypeVariables, Rank2Types #-}
module Asdf where

g :: Num a => a -> (forall a. a -> Int) -> Int
g = flip id

f = g 0 $ \(_ :: forall a. Num a => a) -> 0
>ghc -c asdf.hs
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.0.20081002 for i386-unknown-mingw32):
        types\Type.lhs:(881,0)-(889,46): Non-exhaustive patterns in function tyFamInsts

With 6.8.2 I get instead the following, which I think is correct:

] ghc -XPatternSignatures -c asdf.hs
asdf.hs:7:12:
    Couldn't match expected type `a'
           against inferred type `forall a1. (Num a1) => a1'
      `a' is a rigid type variable bound by
          the polymorphic type `forall a. a -> Int' at asdf.hs:7:4
    In the pattern: _ :: forall a. (Num a) => a
    In the second argument of `($)', namely
        `\ (_ :: forall a. (Num a) => a) -> 0'
    In the expression: g 0 $ \ (_ :: forall a. (Num a) => a) -> 0

On the other hand, replacing f with:

f = g 0 $ ((\_ -> 0) :: forall a. Num a => a -> Int)

Works fine. I don't know why the original code is invalid but it certainly shouldn't cause a panic.

6.10 wasn't available in the "Version" listing so I filed this for 6.9.

Change History (1)

comment:1 Changed 11 years ago by chak

Resolution: fixed
Status: newclosed

This bug is already fixed in GHC 6.10.1 RC 1:

TacticalGrace-3 chak 22 (.../Code/haskell): ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.10.0.20081007
TacticalGrace-3 chak 23 (.../Code/haskell): ghc -c Bug2.hs

Bug2.hs:7:12:
    Pattern signature must exactly match: a
    In the pattern: _ :: forall a. (Num a) => a
    In the second argument of `($)', namely
        `\ (_ :: forall a. (Num a) => a) -> 0'
    In the expression: g 0 $ \ (_ :: forall a. (Num a) => a) -> 0

The compiler you used must have been pulled from darcs just a few hours before I pushed the patch that fixed it.

Nevertheless, the panic points to an infelicity in Type.tyFamInsts that may also cause us grief in other situations; so, I'll fix that.

Thanks for the report!

Note: See TracTickets for help on using tickets.