[GHC] #12563: Bad error message around lack of impredicativity

#12563: Bad error message around lack of impredicativity -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- (Broken out from #12557.) Consider {{{ foo :: ((forall a. f a) -> f r) -> f r foo g = undefined x = \g -> foo g }}} Compiling this code produces {{{ Scratch.hs:24:15: error: • Couldn't match expected type ‘(forall (a :: k). f a) -> f r’ with actual type ‘t’ ‘t’ is a rigid type variable bound by the inferred type of x :: t -> f r at Scratch.hs:24:1-15 • In the first argument of ‘foo’, namely ‘g’ In the expression: foo g In the expression: \ g -> foo g • Relevant bindings include g :: t (bound at Scratch.hs:24:6) x :: t -> f r (bound at Scratch.hs:24:1) }}} The code should be rejected. But, really, the problem is that the type of a lambda-bound variable can't be a polytype (unless the type is obvious at the binding site). We should improve this error message. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12563 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12563: Bad error message around lack of impredicativity -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): This appears to be fixed, as of GHC 8.2.2: {{{ $ /opt/ghc/8.2.2/bin/ghci Bug.hs -XRankNTypes GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Main ( Bug.hs, interpreted ) Bug.hs:4:15: error: • Cannot instantiate unification variable ‘p0’ with a type involving foralls: (forall a. f0 a) -> f0 r0 GHC doesn't yet support impredicative polymorphism • In the first argument of ‘foo’, namely ‘g’ In the expression: foo g In the expression: \ g -> foo g • Relevant bindings include g :: p0 (bound at Bug.hs:4:6) x :: p0 -> f0 r0 (bound at Bug.hs:4:1) | 4 | x = \g -> foo g | ^ }}} I'll add a regression test. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12563#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12563: Bad error message around lack of impredicativity
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott

#12563: Bad error message around lack of impredicativity -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | typecheck/should_fail/T12563 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * testcase: => typecheck/should_fail/T12563 * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12563#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC