Ticket #3692 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

Bogus type error message in type with constraints after the arrow

Reported by: cdfh Owned by:
Priority: normal Milestone: 7.0.1
Component: Compiler Version: 6.12.1
Keywords: TcTyFuns PredType panic Cc:
Operating System: Linux Architecture: x86_64 (amd64)
Type of failure: Compile-time crash Difficulty:
Test Case: typecheck/should_compile/T3692 Blocked By:
Blocking: Related Tickets:

Description

Hello,

I've found a bug, however it may be a duplicate of one of these: #2846, #3272, #3592, #3125, #3102 (roughly in order of duplicate-likelihoodness).

Here's the code:

type Foo a b = () -> (Bar a => a)

class Bar a where {}

foo :: Foo a b
foo = id (undefined :: Foo a b)

And the result of compilation:

$ ghc -fglasgow-exts --make Bug.hs

[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.4 for x86_64-unknown-linux):
  TcTyFuns.flattenType: unexpected PredType
  
  Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

I'm running Gentoo Linux, with dev-lang/ghc-6.10.4 (not dev-haskell/haskell-platform)

Linux geneva 2.6.29-gentoo-r5 #1 SMP Sun Jul 12 03:16:58 BST 2009 x86_64 Intel(R) Core(TM)2 CPU 4300 @ 1.80GHz GenuineIntel GNU/Linux

I'm afraid I've not tested this against HEAD, since I couldn't get it to build.

Note that foo = undefined :: Foo a b does not cause GHC to panic.

Change History

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the report. I can reproduce this in 6.10.4, but HEAD and 6.12 say:

vi.hs:6:10:
    Could not deduce (Bar ((Bar a) => a)) from the context ()
      arising from an expression type signature at vi.hs:6:10-29
    Possible fix:
      add (Bar ((Bar a) => a)) to the context of
        the type signature for `foo'
      or add an instance declaration for (Bar ((Bar a) => a))
    In the first argument of `id', namely `(undefined :: Foo a b)'
    In the expression: id (undefined :: Foo a b)
    In the definition of `foo': foo = id (undefined :: Foo a b)

Changed 3 years ago by simonpj

  • status changed from closed to reopened
  • summary changed from TcTyFuns.flattenType: unexpected PredType to Bogus type error message in type with constraints after the arrow
  • resolution fixed deleted
  • version changed from 6.10.4 to 6.12.1
  • milestone set to 6.14 branch

The error message is totally bogus. I'll fix this in my constraint-solving sweep.

Simon

Changed 3 years ago by igloo

  • milestone changed from 6.14 branch to 6.14.1

Changed 3 years ago by simonpj

  • status changed from new to closed
  • testcase set to typecheck/should_compile/T3692
  • resolution set to fixed

Happily this module compiles fine with the new typechecker. I'll add it as a regression test.

Simon

Note: See TracTickets for help on using tickets.