[GHC] #15380: Infinite typechecker loop in GHC 8.6
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 (Type checker) | Keywords: TypeInType, | Operating System: Unknown/Multiple TypeFamilies | Architecture: | Type of failure: Compile-time Unknown/Multiple | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The following program loops infinitely during typechecking with GHC 8.6.1 and HEAD: {{{#!hs {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeInType #-} {-# LANGUAGE TypeOperators #-} module Bug where import Data.Kind class Generic a where type Rep a :: Type class PGeneric a where type To a (x :: Rep a) :: a type family MDefault (x :: a) :: a where MDefault x = To (M x) class C a where type M (x :: a) :: a type M (x :: a) = MDefault x }}} In GHC 8.4.3, however this fails with a proper error: {{{ $ /opt/ghc/8.4.3/bin/ghc Bug.hs [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) Bug.hs:15:16: error: • Occurs check: cannot construct the infinite kind: a ~ Rep (M x) -> M x • In the type ‘To (M x)’ In the type family declaration for ‘MDefault’ • Type variable kinds: x :: a | 15 | MDefault x = To (M x) | ^^^^^^^^ }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: goldfire (added) * version: 8.4.3 => 8.5 Comment: This regression was introduced in commit faec8d358985e5d0bf363bd96f23fe76c9e281f7 (`Track type variable scope more carefully.`). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => patch * differential: => Phab:D4974 Comment: I really nailed this one. See the patch. :) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): The patch now validates, but waiting for Simon's review before committing. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Richard and I discussed yesterday; he has a bit more to do and then will commmit. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: patch Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Richard Eisenberg <rae@…>): In [changeset:"f8618a9b15177ee8c84771b927cb3583c9cd8408/ghc" f8618a9b/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f8618a9b15177ee8c84771b927cb3583c9cd8408" Remove the type-checking knot. Bug #15380 hangs because a knot-tied TyCon ended up in a kind. Looking at the code in tcInferApps, I'm amazed this hasn't happened before! I couldn't think of a good way to fix it (with dependent types, we can't really keep types out of kinds, after all), so I just went ahead and removed the knot. This was remarkably easy to do. In tcTyVar, when we find a TcTyCon, just use it. (Previously, we looked up the knot-tied TyCon and used that.) Then, during the final zonk, replace TcTyCons with the real, full-blooded TyCons in the global environment. It's all very easy. The new bit is explained in the existing Note [Type checking recursive type and class declarations] in TcTyClsDecls. Naturally, I removed various references to the knot and the zonkTcTypeInKnot (and related) functions. Now, we can print types during type checking with abandon! NB: There is a teensy error message regression with this patch, around the ordering of quantified type variables. This ordering problem is fixed (I believe) with the patch for #14880. The ordering affects only internal variables that cannot be instantiated with any kind of visible type application. There is also a teensy regression around the printing of types in TH splices. I think this is really a TH bug and will file separately. Test case: dependent/should_fail/T15380 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: performance bug | dependent/should_fail/T15380 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: patch => merge * testcase: => dependent/should_fail/T15380 Comment: Fixed now. Though this touches quite a few files, I don't think it should cause merging trouble. But it's not really critical. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: merge Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: | TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: performance bug | dependent/should_fail/T15380 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Posted #15464 as the follow-up TH bug. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#15380: Infinite typechecker loop in GHC 8.6 -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: high | Milestone: 8.6.1 Component: Compiler (Type | Version: 8.5 checker) | Keywords: TypeInType, Resolution: fixed | TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Compile-time | Test Case: performance bug | dependent/should_fail/T15380 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4974 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.6` with 59f38587d44efd00b10a6d98f6a7a1b22e87f13a. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15380#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC