[GHC] #12533: Internal error using redundant forall with default signature

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# LANGUAGE ScopedTypeVariables, DefaultSignatures #-} class Foo x where foo :: forall a . x a -> x a default foo :: forall a . x a -> x a foo x = go where go :: x a go = undefined }}} GHC (7.8.3 and 8.0.1) chokes on the above with the message {{{ Buggy.hs:7:19: error: • GHC internal error: ‘a’ is not in scope during type checking, but it passed the renamer tcl_env of environment: [aoY :-> Type variable ‘x’ = x, ap0 :-> Type variable ‘a’ = a, ap1 :-> Identifier[x::x a, <NotTopLevel>]] • In the first argument of ‘x’, namely ‘a’ In the type signature: go :: x a In an equation for ‘foo’: foo x = go where go :: x a go = undefined }}} If I remove the redundant `forall` it works fine: {{{#!hs class Foo x where foo :: x a -> x a default foo :: forall a . x a -> x a foo x = go where go :: x a go = undefined }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * component: Compiler => Compiler (Type checker) Comment: mniip says this is a renamer problem, with `-ddump-rn` producing {{{#!hs class Main.Foo x_apt where Main.foo :: forall a_apu. x_apt a_apu -> x_apt a_apu default Main.foo :: forall a_apv. x_apt a_apv -> x_apt a_apv Main.foo x_apw = go_apx where go_apx :: x_apt a_apu go_apx = undefined }}} That is, GHC is using `a_apu` when it should be using `a_apv`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | rename/should_compile/T12533 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => rename/should_compile/T12533 Comment: In [changeset:"0050aff22ba04baca732bf5124002417ab667f8a/ghc" 0050aff2/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="0050aff22ba04baca732bf5124002417ab667f8a" Fix scoping of type variables in instances This fixes Trac #12531: class Foo x where foo :: forall a . x a -> x a default foo :: forall b . x b -> x b foo x = go where go :: x b go = undefined We want 'b' to scope over the code for 'foo', but we were using 'a' instead. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 8.0.2
Component: Compiler (Type | Version: 8.0.1
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Compile-time | Test Case:
crash | rename/should_compile/T12533
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
I put the wrong ticket number in the commit message. The full commit is
{{{
commit 0050aff22ba04baca732bf5124002417ab667f8a
Author: Simon Peyton Jones

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | rename/should_compile/T12533 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge Comment: Probably could merge too. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | rename/should_compile/T12533 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dfeuer): That was fast! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | rename/should_compile/T12533 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): The trouble with merging comment:3 is that it requires d2958bd08a049b61941f078e51809c7e63bc3354, which fixes #12220 but which we were thinking on not merging as it causes #12466. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12533: Internal error using redundant forall with default signature -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: crash | rename/should_compile/T12533 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: We managed to sort out the issues described in comment:6. comment:3 merged to `ghc-8.0` as 0e4e03a2a810ffa8ae16815d2ce4aad11d4b1065. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12533#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC