[GHC] #11554: Self quantification in GADT data declarations
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1-rc2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GHC hangs on this (it was panicking on the same code before : [https://github.com/goldfirere/ghc/issues/56](https://github.com/goldfirere/ghc/issues/56) : {{{#!hs {-# LANGUAGE GADTs, TypeInType #-} import Data.Kind data A :: Type where B :: forall (a :: A). A }}} I guess the typechecker tries to infer the kind of A from the type of the constructors and hangs. Maybe recursive occurrences of a type as a kind in its constructors should only be allowed when its kind signature is specified and can be used to typecheck the constructors. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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 bgamari): * keywords: => TypeInType * failure: None/Unknown => Compile-time crash * priority: normal => high * component: Compiler => Compiler (Type checker) * milestone: => 8.0.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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 bgamari): * cc: goldfire (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by bgamari): We're going to just mention this in the user's guide -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"aa611746aa860e1884c9ad623d6939791f2645ff/ghc" aa61174/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="aa611746aa860e1884c9ad623d6939791f2645ff" users-guide: Add references to various issues in bugs section Test Plan: Read it Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2052 GHC Trac Issues: #7411, #11197, #11554, #11715 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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 bgamari): * milestone: 8.0.1 => 8.0.2 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by carlostome): This bug seems to be solved in ghc version 8.1.20160519 (commit 296b8f1baef2e6c88a418bbc5ac8b1ced111c745). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by Rafbill): The bug is still present in this slightly modified example : {{{#!hs {-# LANGUAGE GADTs, TypeInType, RankNTypes #-} import Data.Kind data P (x :: k) = Q data A :: Type where B :: forall (a :: A). P a -> A }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by alexvieth): I have a patch which will reject the example in comment:7 and give this error {{{ • Type constructor ‘A’ cannot be used here (it is defined and used in the same recursive group) • In the kind ‘A’ In the definition of data constructor ‘B’ In the data declaration for ‘A’ }}} The details: - `ATcTyThing` has a new variant `ATcTyConUnpromoted TyCon` meaning the `TyCon` can't be used as a kind. - `tcTyVar` will give a promotion error (`TyConPE`) whenever an `ATcTyConUnpromoted` is encountered and the `TcTyMode` is kind level. - When checking the constructors of a `DataDecl`, the name of the type is associated with an `ATcTyConUnpromoted`, rather than `ATcTyCon` as it is now. Think this is a sane thing to do? If so I'll upload it to phab. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by goldfire): Won't `ATcTyConUnpromoted` and `ATcTyCon` be the same, always? That is, if (and only if) we're currently checking a mutually recursive group containing the tycon `T`, `T` will be registered as `ATcTyCon`. Isn't that the exact scenario where you're proposing to use `ATcTyConUnpromoted`? So my take would be to check in `tcTyVar`, just as you suggest, but use the existing `ATcTyCon` instead of creating something new. Or what am I missing? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by alexvieth):
Or what am I missing?
Nothing, you're right about this. The patch is now very small. {{{ --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -881,7 +881,10 @@ tcTyVar mode name -- Could be a tyvar, a tycon, or a datacon ; case thing of ATyVar _ tv -> return (mkTyVarTy tv, tyVarKind tv) - ATcTyCon tc_tc -> do { check_tc tc_tc + ATcTyCon tc_tc -> do { unless + (isTypeLevel (mode_level mode)) + (promotionErr name TyConPE) + ; check_tc tc_tc ; tc <- get_loopy_tc name tc_tc ; handle_tyfams tc tc_tc } -- mkNakedTyConApp: see Note [Type-checking inside the knot] }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by goldfire): I like it! :) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"430f5c84dac1eab550110d543831a70516b5cac8/ghc" 430f5c8/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="430f5c84dac1eab550110d543831a70516b5cac8" Trac #11554 fix loopy GADTs Summary: Fixes T11554 Reviewers: goldfire, thomie, simonpj, austin, bgamari Reviewed By: thomie, simonpj, bgamari Subscribers: simonpj, goldfire, thomie Differential Revision: https://phabricator.haskell.org/D2283 GHC Trac Issues: #11554 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: merge Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: | Keywords: TypeInType 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 bgamari): * status: new => merge -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11554: Self quantification in GADT data declarations -------------------------------------+------------------------------------- Reporter: Rafbill | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.2 Component: Compiler (Type | Version: 8.0.1-rc2 checker) | Resolution: fixed | Keywords: TypeInType 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 bgamari): * status: merge => closed * resolution: => fixed Comment: Merged as e2335ea283eb05a78fe962d6a00faefacad2292d. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11554#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC