Ticket #3102 (closed merge: fixed)

Opened 4 years ago

Last modified 4 years ago

The impossible happened with implicit parameters

Reported by: Ashley Yakeley Owned by: igloo
Priority: normal Milestone: 6.12.1
Component: Compiler (Type checker) Version: 6.10.1
Keywords: Cc:
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: tyepcheck/should_fail/T3102 Blocked By:
Blocking: Related Tickets:

Description

{-# OPTIONS -XImplicitParams -XRankNTypes #-}
module Bug where

t :: forall a. ((?p :: Int) => a) -> String
t _ = "Hello"

f :: (forall a. a -> String) -> Int
f _ = 3

result :: Int
result = f t
$ ghc -c Bug.hs
ghc: panic! (the 'impossible' happened)
  (GHC version 6.10.1 for x86_64-unknown-linux):
	TcTyFuns.flattenType: unexpected PredType

Change History

Changed 4 years ago by Ashley Yakeley

Note that with this, it compiles fine:

result :: Int
result = f (\a -> t a)

Changed 4 years ago by simonpj

  • owner set to chak
  • difficulty set to Unknown

Manuel, could you look into this, pls?

Simon

Changed 4 years ago by igloo

  • milestone set to 6.12.1

Changed 4 years ago by igloo

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to fixed

In 6.12 and HEAD, we now get a nice error:

u.hs:11:9:
    Occurs check: cannot construct the infinite type:
      a = (?p::Int) => a
    In the first argument of `f', namely `t'
    In the expression: f t
    In the definition of `result': result = f t

Changed 4 years ago by Ashley Yakeley

  • status changed from closed to reopened
  • resolution fixed deleted

Better than panic, but it's still wrong, because "a = (?p::Int) => a" is not an infinite type.

For instance, a = "(?p::Int) => String" satisfies "a = (?p::Int) => a".

Changed 4 years ago by simonpj

  • owner changed from chak to igloo
  • status changed from reopened to new
  • type changed from bug to merge
  • testcase set to tyepcheck/should_fail/T3102

You're right. There was another bug lurking.

Mon Nov 30 09:44:41 PST 2009  simonpj@microsoft.com
  * Fix Trac #3102: pre-matching polytypes
  
  When *pre-matching* two types
       forall a. C1 => t1  ~  forall a. C2 => t2
  we were matching t1~t2, but totally ignoring C1,C2
  That's utterly wrong when pre-matching
         (?p::Int) => String  ~  a
  because we emerge with a:=String!
  
  All this is part of the impredicative story, which is about
  to go away, but still.
  
  Worth merging this to 6.12

    M ./compiler/typecheck/TcUnify.lhs -2 +3

Merge if possible to 6.12.

Thanks for being persistent.

Simon

Changed 4 years ago by igloo

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

Merged

Note: See TracTickets for help on using tickets.