Opened 10 years ago

Closed 9 years ago

#3208 closed bug (fixed)

Incorrect handling of recursive groups with signatures containing equalities and TFs

Reported by: simonpj Owned by: chak
Priority: low Milestone: 7.0.1
Component: Compiler Version: 6.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: T3208a, T3208b
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Jan Jakubuv found this:

{-# OPTIONS -fglasgow-exts #-}
module Foo where

class SUBST s where
    type STerm s

class OBJECT o where
    type OTerm o
    apply :: (SUBST s, OTerm o ~ STerm s) => s -> o

fce' f = fce . apply $ f

fce f = fce' f

yields, with GHC 6.10 or the HEAD:

    ghc: panic! (the 'impossible' happened)
      (GHC version 6.10.2 for i386-unknown-linux):
            idInfo co{v agz} [tv]

Change History (8)

comment:1 Changed 10 years ago by chak

Version: 6.10.26.11

Seems to be related to (if not a duplicate of) #2767.

comment:2 Changed 10 years ago by chak

Resolution: fixed
Status: newclosed

comment:3 Changed 10 years ago by chak

Test Case: T3208

comment:4 Changed 10 years ago by chak

Resolution: fixed
Status: closedreopened
Test Case: T3208T3208a, T3208b

I did fix the original bug, but I noticed another bug in a modified version of the program; hence, I'll reopen the ticket. The problematic variant is the same program, but with the inferred types for fce and fce' added as signatures:

{-# LANGUAGE TypeFamilies #-}

module T3208b where
  
class SUBST s where
    type STerm s

class OBJECT o where
    type OTerm o
    apply :: (SUBST s, OTerm o ~ STerm s) => s -> o

fce' :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
fce' f = fce . apply $ f

fce :: (OTerm a ~ STerm a, OBJECT a, SUBST a) => a -> c
fce f = fce' f

In a debugging compiler (compiled with -DDEBUG), this violates an assertion

ghc-stage1: panic! (the 'impossible' happened)
  (GHC version 6.11.20090807 for i386-apple-darwin):
	ASSERT failed! file compiler/typecheck/TcMType.lhs line 349
t_afI{tv} [tau]

In a compiler without -DDEBUG the program is rejected with the following error message:

T3208b.hs:13:0:
    Couldn't match expected type `STerm b'
           against inferred type `OTerm b'
      NB: `OTerm' is a type function, and may not be injective
      NB: `STerm' is a type function, and may not be injective
    When generalising the type(s) for `fce''

T3208b.hs:13:0:
    Couldn't match expected type `STerm a'
           against inferred type `STerm b'
      NB: `STerm' is a type function, and may not be injective
    When generalising the type(s) for `fce''

comment:5 Changed 10 years ago by chak

Summary: Type family panic (taking the IdInfo of a coercion variable)Incorrect handling of recursive groups with signatures containing equalities and TFs

comment:6 Changed 9 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:7 Changed 9 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:8 Changed 9 years ago by simonpj

Resolution: fixed
Status: newclosed
Type of failure: None/Unknown

The crash has gone. And T3208b is rightly rejected!

Note: See TracTickets for help on using tickets.