[GHC] #9739: GHC 7.8 chokes on recursive classes

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.8.3 checker) | Operating System: Keywords: | Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: Difficulty: Unknown | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Type checking this makes GHC 7.8.3 loop: {{{#!hs {-# LANGUAGE MultiParamTypeClasses #-} module Foo where class Class3 a => Class1 a where class Class2 t a where class2 :: (Class3 t) => a -> m class (Class1 t, Class2 t t) => Class3 t where }}} Does not happen in 7.6.3. I think it's something to do with the `Class3` constraint appearing in `class2`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by ezyang): * version: 7.8.3 => 7.9 Comment: Confirmed to loop on GHC HEAD 75979f3661ff16ec44528a23005ac1be2b9683fe -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by dfeuer): * failure: None/Unknown => Compile-time crash -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by bitonic): Actually, you don't need `MultiParamTypeClasses`: {{{#!hs module Foo where class Class3 a => Class1 a where class Class2 a where class2 :: (Class3 a) => b class (Class1 a, Class2 a) => Class3 a where }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by bitonic): Aaaand with only two classes: {{{!#hs module Foo where class Class2 a => Class1 a where class3 :: (Class2 a) => b class (Class1 a) => Class2 a where }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by dfeuer): * milestone: => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dfeuer): Replying to [comment:4 bitonic]:
Aaaand with only two classes:
{{{#!hs module Foo where
class Class2 a => Class1 a where class3 :: (Class2 a) => b
class (Class1 a) => Class2 a where }}}
The two-class version doesn't loop in 7.9; it just gets an error as it should. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dfeuer): This is interesting: the definition of `Class1` is actually ''illegal'' in Haskell 98, because `class3` constrains the type variable `a`. This sort of thing is only supposed to be allowed with `-XConstrainedClassMethods`. In fact, if you enable that flag, suddenly the compiler realizes there's a loop! So it looks likely that someone made the flag enable the extra loop checking required by such methods, but accidentally failed to make it control whether such things are allowed at all! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | typecheck/should_fail/T9739 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => typecheck/should_fail/T9739 Comment: The 3-class version still loops in HEAD. Reason is this: * `TcTyClsDcls.checkValidClass` is called on each class in turn. * It checks for superclass cycles, and then checks for ambiguity of the method types * The ambiguity check loops if there is a superclass cycle * The superclass cycle check was first, and aborted `checkValidClass` if it failed. * BUT we failed to notice that it would loop if there was a superclass cycle in ''another'' class in the group; and after each class we dust ourselves off and the next one, to get as many validity errors as possible. Solution was simple: make the ambiguity check happen only if there have been no errors so far. Patch coming Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | typecheck/should_fail/T9739 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dfeuer): I don't understand why such a member signature was even allowed without `-XConstrainedClassMethods`. That's essentially a syntax error! Someone also noticed that `Foldable` members currently have a redundant (but harmless) `Foldable` constraint that I think shouldn't have been allowed (I'll take care of those). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes
-------------------------------------+-------------------------------------
Reporter: bitonic | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version: 7.9
(Type checker) | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: Compile- | Related Tickets:
time crash |
Test Case: |
typecheck/should_fail/T9739 |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9739: GHC 7.8 chokes on recursive classes
-------------------------------------+-------------------------------------
Reporter: bitonic | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.10.1
Component: Compiler | Version: 7.9
(Type checker) | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: Compile- | Related Tickets:
time crash |
Test Case: |
typecheck/should_fail/T9739 |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9739: GHC 7.8 chokes on recursive classes -------------------------------------+------------------------------------- Reporter: bitonic | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.9 (Type checker) | Keywords: Resolution: fixed | Architecture: Unknown/Multiple Operating System: | Difficulty: Unknown Unknown/Multiple | Blocked By: Type of failure: Compile- | Related Tickets: time crash | Test Case: | typecheck/should_fail/T9739 | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed Comment: Thanks for reporting this! Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9739#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9739: GHC 7.8 chokes on recursive classes
-------------------------------------+-------------------------------------
Reporter: bitonic | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 7.10.1
Component: Compiler (Type | Version: 7.9
checker) |
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Compile-time | Test Case:
crash | typecheck/should_fail/T9739
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Matthew Pickering

#9739: GHC 7.8 chokes on recursive classes
-------------------------------------+-------------------------------------
Reporter: bitonic | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 7.10.1
Component: Compiler (Type | Version: 7.9
checker) |
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Compile-time | Test Case:
crash | typecheck/should_fail/T9739
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones
participants (1)
-
GHC