[GHC] #8550: GHC builds recursive coerctions when using recursive type families
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------------+------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.6.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Unknown | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- Consider {{{ {-# LANGUAGE TypeFamilies, GADTs, UndecidableInstances #-} type family F a type instance F () = F () data A where A :: F () ~ () => A x :: A x = A }}} On GHC 7.6.3 it yields a context reduction stack overflow (despite F () ~ () being put into the “solved funeqs” list). In HEAD, a recursive dictionary is built, but then detected: {{{ [1 of 1] Compiling Foo ( Foo.hs, Foo.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131108 for x86_64-unknown-linux): Cycle in coercion bindings [[cobox_ayX{v} [lid] = CO main:Foo.TFCo:R:F(){tc rob}[0] ; cobox_ayZ{v} [lid], cobox_ayZ{v} [lid] = CO cobox_ayX{v} [lid] ; cobox_az0{v} [lid]]] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Either this panic needs to be turned into an error, or we need to prevent recursive dictionaries for when solving funeqs (similar to how we do it for `Coercible`). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Changes (by nomeata): * version: 7.6.3 => -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by monoidal): Could you check whether it works now? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by nomeata): Yes, same thing. What would make you think it changed since two weeks ago? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by monoidal): Sorry, I couldn't reproduce; now I see the panic needs compiling with DEBUG. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by nomeata): Ah, ok. Did not try that. What happens when you actually run the code? I assume it will just loop... -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families --------------------------------------------+------------------------------ Reporter: nomeata | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by monoidal): Right. `main = seq A (return ())` loops. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: (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 thomie): * priority: normal => high * milestone: => 7.10.1 Old description:
Consider {{{ {-# LANGUAGE TypeFamilies, GADTs, UndecidableInstances #-} type family F a type instance F () = F () data A where A :: F () ~ () => A x :: A x = A }}}
On GHC 7.6.3 it yields a context reduction stack overflow (despite F () ~ () being put into the “solved funeqs” list).
In HEAD, a recursive dictionary is built, but then detected: {{{ [1 of 1] Compiling Foo ( Foo.hs, Foo.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131108 for x86_64-unknown-linux): Cycle in coercion bindings [[cobox_ayX{v} [lid] = CO main:Foo.TFCo:R:F(){tc rob}[0] ; cobox_ayZ{v} [lid], cobox_ayZ{v} [lid] = CO cobox_ayX{v} [lid] ; cobox_az0{v} [lid]]]
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}}
Either this panic needs to be turned into an error, or we need to prevent recursive dictionaries for when solving funeqs (similar to how we do it for `Coercible`).
New description: Consider {{{ {-# LANGUAGE TypeFamilies, GADTs, UndecidableInstances #-} type family F a type instance F () = F () data A where A :: F () ~ () => A x :: A x = A main = seq A (return ()) }}} On GHC 7.6.3 it yields a context reduction stack overflow (despite F () ~ () being put into the “solved funeqs” list). In HEAD, a recursive dictionary is built, but then detected: {{{ [1 of 1] Compiling Foo ( Foo.hs, Foo.o ) ghc-stage2: panic! (the 'impossible' happened) (GHC version 7.7.20131108 for x86_64-unknown-linux): Cycle in coercion bindings [[cobox_ayX{v} [lid] = CO main:Foo.TFCo:R:F(){tc rob}[0] ; cobox_ayZ{v} [lid], cobox_ayZ{v} [lid] = CO cobox_ayX{v} [lid] ; cobox_az0{v} [lid]]] Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Either this panic needs to be turned into an error, or we need to prevent recursive dictionaries for when solving funeqs (similar to how we do it for `Coercible`). -- Comment: Trying to compile the example from the description with ghc-7.9.20141115 results in GHC using lots of memory, making my machine unusable until I kill the process. This seems like a regression, setting priority to high. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler (Type | Version: checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * cc: goldfire (added) Comment: Richard any comments? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler (Type | Version: checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7788 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * related: => #7788 Comment: This looks like a duplicate of #7788. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: new Priority: high | Milestone: 7.12.1 Component: Compiler (Type | Version: checker) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7788 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by Richard Eisenberg <eir@…>): In [changeset:"c1edbdfd9148ad9f74bfe41e76c524f3e775aaaa/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="c1edbdfd9148ad9f74bfe41e76c524f3e775aaaa" Do proper depth checking in the flattener to avoid looping. This implements (roughly) the plan put forward in comment:14:ticket:7788, fixing #7788, #8550, #9554, #10139, and addressing concerns raised in #10079. There are some regressions w.r.t. GHC 7.8, but only with pathological type families (like F a = F a). This also (hopefully -- don't have a test case) fixes #10158. Unsolved problems include #10184 and #10185, which are both known deficiencies of the approach used here. As part of this change, the plumbing around detecting infinite loops has changed. Instead of -fcontext-stack and -ftype-function-depth, we now have one combined -freduction-depth parameter. Setting it to 0 disbales the check, which is now the recommended way to get (terminating) code to typecheck in releases. (The number of reduction steps may well change between minor GHC releases!) This commit also introduces a new IntWithInf type in BasicTypes that represents an integer+infinity. This type is used in a few places throughout the code. Tests in indexed-types/should_fail/T7788 indexed-types/should_fail/T8550 indexed-types/should_fail/T9554 indexed-types/should_compile/T10079 indexed-types/should_compile/T10139 typecheck/should_compile/T10184 (expected broken) typecheck/should_compile/T10185 (expected broken) This commit also changes performance testsuite numbers, for the better. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#8550: GHC builds recursive coerctions when using recursive type families -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: closed Priority: high | Milestone: 7.12.1 Component: Compiler (Type | Version: checker) | Keywords: Resolution: fixed | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- Blocked By: | types/should_fail/T8550 Related Tickets: #7788 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * testcase: => indexed-types/should_fail/T8550 * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8550#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC