[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 <simonpj@…>): In [changeset:"7c79633688238086ad60e1d23e0a424bb4eb325f/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="7c79633688238086ad60e1d23e0a424bb4eb325f" Fix the superclass-cycle detection code (Trac #9739) We were falling into an infinite loop when doing the ambiguity check on a class method, even though we had previously detected a superclass cycle. There was code to deal with this, but it wasn't right. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9739#comment:11> 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 <simonpj@…>): In [changeset:"c639560d8ad969415033b19201d9626b1a0638bf/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="c639560d8ad969415033b19201d9626b1a0638bf" Test Trac #9739 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9739#comment:10> 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 | 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 <matthewtpickering@…>): In [changeset:"44640af7afa1a01ff2e2357f7c1436b4804866fc/ghc" 44640af7/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="44640af7afa1a01ff2e2357f7c1436b4804866fc" Allow as-patterns in pattern synonym declarations. We can allow them if they contain no free variables. This patch just allows them in one direction and not to be used as builders as the original ticket suggests. Test Plan: ./validate Reviewers: austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1666 GHC Trac Issues: #9739 Conflicts: testsuite/tests/patsyn/should_fail/all.T }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9739#comment:13> 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 Simon Peyton Jones <simonpj@…>): In [changeset:"48e06346805ab882a54088e01e5224111182f5df/ghc" 48e0634/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="48e06346805ab882a54088e01e5224111182f5df" Revert "Allow as-patterns in pattern synonym declarations." I'm reverting this until we agree a design. See comment:5 in Trac #9793. Incidentally the reference to Trac #9739 in the reverted patch is bogus; it shold have said #9793. This reverts commit 44640af7afa1a01ff2e2357f7c1436b4804866fc. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9739#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC