Opened 6 years ago

Closed 6 years ago

#8142 closed bug (fixed)

Panic on TypeFamilies compile

Reported by: zenzike Owned by: jstolarek
Priority: normal Milestone:
Component: Compiler Version: 7.6.3
Keywords: Cc:
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: typecheck/should_fail/T8142.hs
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following code produces a panic:

> {-# LANGUAGE TypeFamilies #-}

> module Bug where

> tracer :: (Functor f, Coinductive f) => (c -> f c) -> (c -> f c)
> tracer = h where h = (\(_, b) -> ((outI . fmap h) b)) . out

> class Functor g => Coinductive g where
>   type Nu g :: *
>   out     :: Nu g -> g (Nu g)
>   outI    :: g (Nu g) -> Nu g

Compiling with ghc-7.6.3 gives:

$ ghc Bug.lhs
[1 of 1] Compiling Bug              ( Bug.lhs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.3 for x86_64-apple-darwin):
        cgLookupPanic (probably invalid Core; try -dcore-lint)
    h{v aeN} [lid]
    static binds for:
    local binds for:
    main:Bug.outI{v r0} [gid[ClassOp]]
    main:Bug.out{v r1} [gid[ClassOp]]
    main:Bug.$p1Coinductive{v reT} [gid[ClassOp]]

Please report this as a GHC bug:

Change History (5)

comment:1 Changed 6 years ago by dreixel

Seems to be fixed in HEAD:

    Couldn't match type ‛Nu f0’ with ‛Nu f’
    NB: ‛Nu’ is a type function, and may not be injective
    The type variable ‛f0’ is ambiguous
    Expected type: a -> Nu f
      Actual type: a -> Nu f0
    When checking that ‛h’
      has the inferred type ‛forall (f :: * -> *) a. a -> Nu f’
    Probable cause: the inferred type is ambiguous
    In an equation for ‛tracer’:
          = h
              h = (\ (_, b) -> ((outI . fmap h) b)) . out

    Occurs check: cannot construct the infinite type: a ~ f1 a
    Expected type: a -> (t0, f1 a)
      Actual type: Nu ((,) t0) -> (t0, Nu ((,) t0))
    Relevant bindings include h :: a -> Nu f1 (bound at Test.hs:6:18)
    In the second argument of ‛(.)’, namely ‛out’
    In the expression: (\ (_, b) -> ((outI . fmap h) b)) . out

comment:2 Changed 6 years ago by jstolarek

Is this the same as #7729? I think we could add that program as yet another test to the testsuite.

comment:3 Changed 6 years ago by jstolarek

Owner: set to jstolarek

comment:4 Changed 6 years ago by Jan Stolarek <jan.stolarek@…>

In 0158d71a121007f0de35ba7b94f255fc79f0f59f/testsuite:

Add regression test for #8142

comment:5 Changed 6 years ago by jstolarek

Resolution: fixed
Status: newclosed
Test Case: typecheck/should_fail/T8142.hs
Note: See TracTickets for help on using tickets.